_form_set_class

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 – drupal7 _form_set_class(&$element, $class = array())

Sets a form element's class attribute.

Adds 'required' and 'error' classes as needed.

Übergabeparameter

&$element The form element.

$name Array of new class names to be added.

Verwandte Themen

▾ 7 functions call _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.
theme_textarea in includes/form.inc
Format a textarea.
theme_textfield in includes/form.inc
Format a textfield.

Code

includes/form.inc, line 2246

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

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen