function theme_options in Options Element 6
Same name and namespace in other branches
- 7 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($element) {
drupal_add_js('misc/tabledrag.js');
drupal_add_js(drupal_get_path('module', 'options_element') . '/options_element.js');
drupal_add_css(drupal_get_path('module', 'options_element') . '/options_element.css');
$classes = array();
if (isset($element['#attributes']['class'])) {
$classes[] = $element['#attributes']['class'];
}
$classes[] = 'form-options';
$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 class="' . implode(' ', $classes) . '">';
$output .= theme('fieldset', array(
'#title' => t('Options'),
'#collapsible' => FALSE,
'#children' => $options,
'#attributes' => array(
'class' => 'options',
),
));
if (!empty($settings)) {
$output .= theme('fieldset', array(
'#title' => t('Option settings'),
'#collapsible' => FALSE,
'#children' => $settings,
'#attributes' => array(
'class' => 'option-settings',
),
));
}
$output .= '</div>';
return $output;
}