function theme_options in Options Element 7
Same name and namespace in other branches
- 6 options_element.inc \theme_options()
Theme an options element.
File
- ./
options_element.inc, line 12 - All logic for options_element form elements.
Code
function theme_options($variables) {
$element = $variables['element'];
element_set_attributes($element, array(
'id',
));
_form_set_class($element, array(
'form-options',
));
$classes =& $element['#attributes']['class'];
$classes[] = 'options-key-type-' . $element['#key_type'];
if ($element['#key_type_toggled']) {
$classes[] = 'options-key-custom';
}
if (isset($element['#optgroups']) && $element['#optgroups']) {
$classes[] = 'options-optgroups';
}
if (isset($element['#multiple']) && $element['#multiple']) {
$classes[] = 'options-multiple';
}
// Replace the error class from wrapper div, which doesn't display well with
// complex elements like Options Element.
if ($key = array_search('error', $classes, TRUE)) {
$classes[$key] = 'options-error';
}
$options = '';
$options .= drupal_render($element['options_field']);
if (isset($element['default_value_field'])) {
$options .= drupal_render($element['default_value_field']);
}
if (isset($element['default_value_pattern'])) {
$options .= drupal_render($element['default_value_pattern']);
}
$settings = '';
if (isset($element['custom_keys'])) {
$settings .= drupal_render($element['custom_keys']);
}
if (isset($element['multiple'])) {
$settings .= drupal_render($element['multiple']);
}
if (isset($element['option_settings'])) {
$settings .= drupal_render($element['option_settings']);
}
$output = '';
$output .= '<div' . drupal_attributes($element['#attributes']) . '>';
$output .= theme('container', array(
'element' => array(
'#title' => t('Options'),
'#collapsible' => FALSE,
'#children' => $options,
'#attributes' => array(
'class' => array(
'options',
),
),
),
));
if (!empty($settings)) {
$output .= theme('fieldset', array(
'element' => array(
'#title' => t('Option settings'),
'#collapsible' => FALSE,
'#children' => $settings,
'#attributes' => array(
'class' => array(
'option-settings',
),
),
),
));
}
$output .= '</div>';
return $output;
}