function theme_select_as_radios_details in Better Exposed Filters 8.3
Themes a select element as radio buttons enclosed in a details element.
Parameters
array $vars: An array of arrays, the 'element' item holds the properties of the element.
Return value
string HTML representing the form element.
File
- ./
better_exposed_filters.theme, line 142 - Provides theming functions to display exposed forms using different interfaces.
Code
function theme_select_as_radios_details($vars) {
// Merge incoming element with some default values. Prevents a lot of this.
// $foo = isset($bar) ? $bar : $bar_default;
$element = array_merge(array(
'#bef_title' => '',
'#bef_description' => '',
'#bef_operator' => array(),
), $vars['element']);
// The "all" option is the first in the list. If the selected radio button is
// the all option, then leave the details element collapsed. Otherwise,
// render it opened.
$keys = array_keys($element['#options']);
$all = array_shift($keys);
$details = array(
'#title' => $element['#bef_title'],
'#description' => $element['#bef_description'],
'#attributes' => array(
'class' => array(
'bef-select-as-checkboxes-details',
),
),
);
// We rendered the description as part of the details element, don't render
// it again along with the checkboxes.
unset($element['#bef_description']);
$children = '';
if (!empty($element['#bef_operator'])) {
// Put an exposed operator inside the fieldset.
$children = drupal_render($element['#bef_operator']);
}
// Render the radio buttons.
// @TODO: render in a template
$children .= theme('select_as_radios', $element);
$details['#children'] = $children;
// @TODO: render in a template
return theme('fieldset', array(
'element' => $details,
));
}