Apologies for not having a patch that actually fixes this issue, but I'm rather new to the 4.7 forms API and this bug is definitely caused by some weirdness I don't quite follow.

I've got a 4.7 test site with the latest CVS copies of core and project installed. i created a single taxonomy term for the categories of projects, and created a single test project with issue tracking enabled.

whenever i try to create a new issue (either as a site admin, or as an anonymous user), i'm getting a stray '1' showing up in the "Input format" box, and none of the radio buttons are selected by default. at first, it was pretty hard to figure out where this '1' was coming from, but i tracked it down to the following:

function project_form_alter(...) {
...
  $form['issue_details']['format']['format'][variable_get('filter_default_format', 1)]['#value'] = 1;

if i comment out that line, the 1 goes away. however, in that case, there's still no radio selected for the input format. :( i tried a few modifications to this line, but nothing i did managed to get any of the radio buttons selected by default. cvs annotate shows this line came from:

1.139 (thehunmo 08-Nov-05)

cvs log shows:

----------------------------
revision 1.139
date: 2005-11-08 18:23:01 +0000;  author: thehunmonkgroup;  state: Exp;  lines: +22 -20;
changes to hook form alter to coincide w/ pending core changes

a few observations:

  1. according to http://drupaldocs.org/api/head/file/contributions/docs/developer/topics/..., the 'radios' form type wants an entitied called "#default_value" not "#value".
  2. from dumping out the contents of $form['issue_details']['format'], it seems that the array is structued like:
           $form['issue_details']['format']
                                                         [1]
                                                              [stuff for format filter #1...]
                                                         [2]
                                                              [stuff for format filter #2...]
           ...
    

    everything appears to be setup properly for rendering a set of radio buttons where the first is set:

     -- format[1] --
    #type: radio
    #title: Filtered HTML
    #default_value: 1
    #return_value: 1
    #parents: Array
    #description:
    
        * Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
        * Lines and paragraphs break automatically.
    
    
    -- format[2] --
    #type: radio
    #title: PHP code
    #default_value: 1
    #return_value: 2
    #parents: Array
    #description:
    
        * You may post PHP code. You should include <?php ?> tags.
    
    
    -- format[3] --
    #type: radio
    #title: Full HTML
    #default_value: 1
    #return_value: 3
    #parents: Array
    #description:
    
        * Lines and paragraphs break automatically.
    

i don't claim to understand hook form_alter() or the forms API itself well enough to get to the bottom of this, but i know what's there is broken. ;) i'm just going to create this issue and email chad about it, so perhaps he can fix this for us.

thanks,
-derek

CommentFileSizeAuthor
#10 project_issue_form_submit.patch1.05 KBdww

Comments

pfaocle’s picture

Can reproduce this one.

dww’s picture

thanks. i was about to follow-up to make sure i wasn't the only one seeing this. i did try with both safari and firefox and saw the same thing...

pfaocle’s picture

For a start, I think $form['issue_details']['format']['format'] should be $form['issue_details']['format']. Still checking this one out. I think its down to some confusion between $value, $default_value and $return_value...

Have some debug info. Before (unpatched, apart from the above mentioned removal of an extra ['format'])::

[format] => Array
                (
                    [#type] => fieldset
                    [#title] => Input format
                    [#collapsible] => 1
                    [#collapsed] => 1
                    [#weight] => 
                    [1] => Array
                        (
                            [#type] => radio
                            [#title] => Filtered HTML
                            [#default_value] => 5
                            [#return_value] => 1
                            [#parents] => Array
                                (
                                    [0] => format
                                )

                            [#description] => '' // stuff
                        )

                    [2] => Array
                        (
                            [#type] => radio
                            [#title] => PHP code
                            [#default_value] => 5
                            [#return_value] => 2
                            [#parents] => Array
                                (
                                    [0] => format
                                )

                            [#description] =>  '' // stuff
                        )

                    [3] => Array
                        (
                            [#type] => radio
                            [#title] => Full HTML
                            [#default_value] => 5
                            [#return_value] => 3
                            [#parents] => Array
                                (
                                    [0] => format
                                )

                            [#description] =>   '' // stuff
                        )

                    [5] => Array
                        (
                            [#type] => radio
                            [#title] => Markdown
                            [#default_value] => 5
                            [#return_value] => 5
                            [#parents] => Array
                                (
                                    [0] => format
                                )

                            [#description] =>   '' // stuff
                        )

                )

After form_alter:

[format] => Array
                (
                    [#type] => fieldset
                    [#title] => Input format
                    [#collapsible] => 1
                    [#collapsed] => 1
                    [#weight] => 
                    [1] => Array
                        (
                            [#type] => radio
                            [#title] => Filtered HTML
                            [#default_value] => 5
                            [#return_value] => 1
                            [#parents] => Array
                                (
                                    [0] => format
                                )

                            [#description] =>   '' // stuff
                        )

                    [2] => Array
                        (
                            [#type] => radio
                            [#title] => PHP code
                            [#default_value] => 5
                            [#return_value] => 2
                            [#parents] => Array
                                (
                                    [0] => format
                                )

                            [#description] =>   '' // stuff
                        )

                    [3] => Array
                        (
                            [#type] => radio
                            [#title] => Full HTML
                            [#default_value] => 5
                            [#return_value] => 3
                            [#parents] => Array
                                (
                                    [0] => format
                                )

                            [#description] =>   '' // stuff
                        )

                    [5] => Array
                        (
                            [#type] => radio
                            [#title] => Markdown
                            [#default_value] => 5
                            [#return_value] => 5
                            [#parents] => Array
                                (
                                    [0] => format
                                )

                            [#description] =>   '' // stuff
                            [#value] => 1
                        )

                )
hunmonk’s picture

that spurious line of code is part of an evil hack to fool the forms API into not validating the second page of the issue submission wizard, IIRC. the last i checked, you really can't do multi-part node forms w/o this issue cropping up. the api tries to validate the second page of the form upon initial display, so you have to inject some values to bypass it. i'm guessing the structure of the filter form changed. looking into it now...

hunmonk’s picture

Assigned: Unassigned » hunmonk
Status: Active » Fixed

yep, that was it. just had to revisit the exact path to set the default value for the filter format. i hope in the future the forms api will handle multipart node forms w/o having to resort to such 'creative' solutions... ;)

fix committed to HEAD version of the module.

pfaocle’s picture

Status: Fixed » Active

I'm afraid this hasn't fixed anything here. The only change seems to be now the 'description' field is marked with an error (as a required field - the #validated flag is no longer TRUE). The default input format still hasn't been selected.

pfaocle’s picture

Hmm - works on a clean install of Drupal HEAD and latest project, tho. The default filter format on my test site (with an existing, populated db) isn't one of the three 'core' formats however - I have a 4th one for 'Markdown', which isn't being selected.

hunmonk’s picture

Status: Active » Fixed

whoop. nice catch :)

we can't set the value to 1, we have to set it to the value of the default format!

fixed in HEAD.

pfaocle’s picture

Nice one. Should the description box still be getting validated on clicking 'next'? Or is this now required to set the default filter format?

dww’s picture

Assigned: hunmonk » dww
Status: Fixed » Reviewed & tested by the community
StatusFileSize
new1.05 KB

still broken in two ways:

  1. if i apply all the changes from last night, it (mostly) works as an authenticated use, but i still get a stray 1 when i try to create an issue as an anonymous user. in this case, there's no array of $form['issue_details']['format'][format_integer] options, there's just a single default format used for anonymous, and therefore, no radio buttons to set a value in.
  2. in both the auth or anon case, as soon as i land on the 2nd stage of the form, i get a red warning:
    Description field is required.
    

    the attached patch fixes both. i'll apply to HEAD.

    -derek

dww’s picture

Status: Reviewed & tested by the community » Fixed

commited to HEAD (revision 1.151)

hunmonk’s picture

good catch. also, the description field had some funky form code in it that was supposed to make it conditionally required, but it wasn't working--after checking w/ killes i changed it to make that field always required, and committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)