_form_set_class

Versions
5 – 7
_form_set_class(&$element, $class = array())

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

▾ 9 functions call _form_set_class()

theme_assetfield in contributions/asset/asset_wizard.module
Format an assetfield.
theme_checkbox in 5/includes/form.inc
Format a checkbox.
theme_file in 5/includes/form.inc
Format a file upload field.
theme_fivestar_select in contributions/fivestar/fivestar.module
Theme the straight HTML version of the fivestar select list. This is used to remove the wrapping 'form-item' div from the select list.
theme_password in 5/includes/form.inc
Format a password field. *
theme_radio in 5/includes/form.inc
Format a radio button.
theme_select in 5/includes/form.inc
Format a dropdown menu or scrolling selection box.
theme_textarea in 5/includes/form.inc
Format a textarea.
theme_textfield in 5/includes/form.inc
Format a textfield.

Code

5/includes/form.inc, line 1578

<?php
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);
}
?>