function theme_select_with_style_select in Select with Style 7
Returns HTML for a select form element.
It is possible to group options together as "optgroups" sub-elements of the select. To do this, change the format of $options to an associative array in which the keys are group labels, and the values are associative arrays in the normal #options format. Note that while you can nest optgroups through this function, your browser may not honour deep nesting and flatten the optgroups hierarchy to one level. For fine-grained styling of the HTML select options, $variables may include $variables['element']['#option_attributes'], an array indexed by the same keys as variables['element']['#options'], but containing CSS attributes, in the manner of #attributes.
Parameters
$variables: An associative array containing:
- element: An associative array containing the properties of the element. Properties used: #title, #value, #options, #option_attributes, #description, #extra, #multiple, #required, #name, #attributes, #size.
File
- select_with_style/
select_with_style.theme.inc, line 30 - select_with_style.theme.inc
Code
function theme_select_with_style_select($variables) {
$element = $variables['element'];
if (!isset($element['#option_attributes'])) {
// Fall back to the original.
return theme_select($variables);
}
element_set_attributes($element, array(
'id',
'name',
'size',
));
_form_set_class($element, array(
'form-select',
'with-style',
));
return '<select ' . drupal_attributes($element['#attributes']) . '>' . select_with_style_select_options($element) . '</select>';
}