function _form_set_class in Drupal 4
Same name and namespace in other branches
- 5 includes/form.inc \_form_set_class()
- 6 includes/form.inc \_form_set_class()
- 7 includes/form.inc \_form_set_class()
Sets a form element's class attribute.
Adds 'required' and 'error' classes as needed.
Parameters
&$element: The form element
$name: Array of new class names to be added
Related topics
7 calls to _form_set_class()
- theme_checkbox in includes/
form.inc - Format a checkbox.
- theme_file in includes/
form.inc - Format a file upload field.
- theme_password in includes/
form.inc - Format a password field.
- theme_radio in includes/
form.inc - Format a radio button.
- theme_select in includes/
form.inc - Format a dropdown menu or scrolling selection box.
File
- includes/
form.inc, line 1169
Code
function _form_set_class(&$element, $class = array()) {
if ($element['#required']) {
$class[] = 'required';
}
if (form_get_error($element)) {
$class[] = 'error';
}
if (isset($element['#attributes']['class'])) {
$class[] = $element['#attributes']['class'];
}
$element['#attributes']['class'] = implode(' ', $class);
}