views:

83

answers:

2

I really don't get why this is not working. I want to avoid a specific form item being collapsed.

This is my element I want to modify (after the change with the code below):

 [taxonomy] => Array
        (
            [tags] => Array
                (
                    [1] => Array
                        (
                            [#type] => textfield
                            [#title] => Tags
                            [#description] => A comma-separated list of terms describing this content. Example: funny, bungee jumping, "Company, Inc.".
                            [#required] => 0
                            [#default_value] => 
                            [#autocomplete_path] => taxonomy/autocomplete/1
                            [#weight] => 0
                            [#maxlength] => 1024
                            [#collapsed] => 0
                            [#collapsible] => 0
                        )

                    [#collapsed] => 0
                    [#collapsible] => 0
                )

            [#weight] => -3
            [#tree] => 1
            [#collapsed] => 0
            [#collapsible] => 0

This is my code in hook_form_alter (I'm sure the form is modified by the code):

 $form['taxonomy']['#collapsed'] = 0;
 $form['taxonomy']['tags']['#collapsed'] = 0;
 $form['taxonomy']['tags'][2]['#collapsed'] = 0;

 $form['taxonomy']['#collapsible'] = 0;
 $form['taxonomy']['tags']['#collapsible'] = 0;
 $form['taxonomy']['tags'][3]['#collapsible'] = 0;

But it doesn't work. The element is always collapsed. And I've refreshed all caches alt text

http://dl.dropbox.com/u/72686/tagsform.txt

Update2:

$form['taxonomy']['#required'] = TRUE;
$form['taxonomy']['tags']['#required'] = TRUE;
$form['taxonomy']['tags'][5]['#required'] = TRUE;

alt text

A: 

There should be some theme_ or pre_process_ function that change the way the output is printed, i can't see checkboxes under the textfield in $form array... Where comes these checkboxes, may come the fieldset.

Tarentrulle
@Tarentrulle I thought I could specify "collapsing" property for all elements in hook_form_alter. Instead some modules bypass it ? by process the element before ? By the way the module is Taxonomy SuperSelect (drupal.org/project/taxonomy_super_select)
Patrick
@Patrick @Henrik-Opel got the point, in taxonomy_super_select, there is a marvellous ''taxonomy_super_select_form_alter'' which ''unset($form['taxonomy']['tags'][$vid]);'' and then ''$form['taxonomy']['tags'][...]'' is rebuild by the module
Tarentrulle
i didn't go so deep in the code, but i looks like if you set the taxonomy as requiered it will be expanded
Tarentrulle
@Tarentrulle: well I've added "Required" attribute but it doesn't work. I've updated the question with the latest code. Furthermore, I cannot make it "Required", so this would be another issue in the future for sure.
Patrick
A: 

From the array you posted, it looks like you try to adjust the form element before taxonomy module actually turned it into a fieldset (note that there is no '#type' => 'fieldset' declaration in that array). If you take look at taxonomy_form_alter(), you can see that it is in that hook_form_alter() implementation, that the taxonomy array in the node gets 'converted' into actual forms API elements.

So my guess is that your adjustments reside in a hook_form_alter() implementation that runs before that of the taxonomy module, so that your declarations for the collapsed states get overwritten by taxonomy module immediately after you set them.

Try to adjust your modules weight to something higher than that of taxonomy module and see if this changes things. (Be aware that changing the weight might effect other things that your module does, so test carefully after doing it!)

Henrik Opel
@Henrik Opel ok, We are nearer, but still not perfect. I've decreased the weight of the module taxonomy (-9) and superselect Taxonomy (-10) and I've attached the new screenshot to the question. As you can see there is an improvement but still the checkboxes are not displayed. I tried to play with these value (i.e. taxonomy (-11 or -10) but I can only get this result or the total collapsing.
Patrick
in general I try to make my custom module the last one being run so I'll give it a weight of something crazy high. Since you can then be confident that the arrays you are getting are not going to be messed with by contrib modules. I would try putting your module last and then post the array that is output. Should be able to make the changes from there
mirzu
@Patrick: I suggested to alter your modules weight, not that of the others. You should _never_ change a core modules weight, until you know exactly what you are doing! Also, Taxonomy Super Select would set its weight to [taxonomy weight]+1, so it wants to run _after_ taxonomy (you set it to run before).
Henrik Opel
@Patrick: Taxonomy Super Select heavily manipulates the taxonomy form handling (you should mention the use of this module in your question). So I'd suggest that you reset your changes to the modules weights, remove your code changes, set _your_ modules weight to something higher than taxonomy super select, and inspect (and post) the resulting array from your hook_form_alter implementation. You should find a proper fieldset definition in there, which you then should be able to adjsut concerning the collapsible/collapsed properties.
Henrik Opel

related questions