Fieldsets with #collapsible=TRUE don't work correctly and mix up the sub-elements order in certain situations. The bug appears when inserting theme('filter_tips', ...) into the #description of a form element.
The FAPI code below makes the "input formats:" text of drupals standard theme move to the bottom of the fieldset. When collapsing the fieldset, the text moves out of the fieldset.
// get filter tips and set fieldset parameters
$filter_tips_wrapper = array(
'#title' => t('Formatting hints'),
'#collapsible' => TRUE, // define as collapsible. If not, the bug won't appear!
'#collapsed' => TRUE,
'#value' => theme('filter_tips', _filter_tips(-1, FALSE), TRUE),
);
$newmail_form['newmail']['body'] = array(
'#type' => 'textarea',
'#title' => t('Your Message'),
'#cols' => 60,
'#rows' => 8,
'#weight' => 3,
'#required' => true,
'#description' => theme('fieldset', $filter_tips_wrapper), // put the fieldset into mail body description
'#default_value' => $preview_body,
);
I think it's a javascript bug of FAPI.
Comments
Comment #1
Anonymous (not verified) commentedA quick fix is to put all fieldset content into <div> like
Comment #2
catchYeah the current fix is to put any text into a div. I'm not sure if there's a duplicate issue, but this will need to be fixed against HEAD then backported, so moving there for now.
Comment #3
edmund.kwok commentedIn line 75 of collapse.js
Hmm, it seems that the text 'input formats:' is left out of the fieldset because it is not enclosed in any tags. I'm not very sure about DOM, but I think since the text is not in any tag, it is not considered a child of the fieldset. So one possible fix that is specific to your case is to overwrite theme_filter_tips and enclose the text in a tag.
For a general fix in core, I'm not sure what if there is any function to obtain the text which is not considered a chid. Perhaps a guideline can be provided stating that any text in a collapsible fieldset should be enclosed in a tag?
Comment #6
casey commentedFixed in D7: #676800: Fieldsets break design badly