| 5 form.inc | theme_fieldset($element) |
| 6 form.inc | theme_fieldset( |
| 7 form.inc | theme_fieldset($variables) |
| 8 form.inc | theme_fieldset($variables) |
Returns HTML for a fieldset form element and its children.
Parameters
$variables: An associative array containing:
- element: An associative array containing the properties of the element. Properties used: #attributes, #children, #collapsed, #collapsible, #description, #id, #title, #value.
Related topics
File
- includes/
form.inc, line 2740 - Functions for form and batch generation and processing.
Code
function theme_fieldset($variables) {
$element = $variables['element'];
element_set_attributes($element, array('id'));
_form_set_class($element, array('form-wrapper'));
$output = '<fieldset' . drupal_attributes($element['#attributes']) . '>';
if (!empty($element['#title'])) {
// Always wrap fieldset legends in a SPAN for CSS positioning.
$output .= '<legend><span class="fieldset-legend">' . $element['#title'] . '</span></legend>';
}
$output .= '<div class="fieldset-wrapper">';
if (!empty($element['#description'])) {
$output .= '<div class="fieldset-description">' . $element['#description'] . '</div>';
}
$output .= $element['#children'];
if (isset($element['#value'])) {
$output .= $element['#value'];
}
$output .= '</div>';
$output .= "</fieldset>\n";
return $output;
}
Login or register to post comments
Comments
Theme fieldset may require form.js
Correct me if i am wrong but i have found that if you are trying to do collapsible fieldsets on a non form element you may need to include form.js AND collapse.js to your page. You also need to add the 'collapsible' and 'colllapsed' classes manually.
example:
$fieldset => array('#theme' => 'fieldset',
'#title' => 'my fieldset',
//doesn't make fields collapsible
'#collapsible' => TRUE,
// although the following works
'#attached' => array(
'js' => array(
'misc/form.js',
'misc/collapse.js',
),
),
'#attributes' => array(
'class' => array('collapsible', 'collapsed'),
),
);
Give it a try and let me know.
This does work
Although, if anyone is confused as to why it works (like I was) here are some links read this:
http://drupal.org/node/930760
and watch this:
http://chicago2011.drupal.org/sessions/render-api-drupal-7
Which explains the new Render API in Drupal 7
That video was amazing,
That video was amazing, thanks for posting, it cleared up many things in my head and it was easy to follow for a Drupal newbie like me.
Core Issue #1099132
I thought this may be of interest to users dealing with collapsible fieldset issues -> #1099132
Core Issue #1099132
I thought this may be of interest to users dealing with collapsible fieldset issues -> http://drupal.org/node/1099132