function theme_form_element

7.x form.inc theme_form_element($variables)
6.x form.inc theme_form_element($element, $value)

Return a themed form element.

Parameters

element: An associative array containing the properties of the element. Properties used: title, description, id, required

$value: The form element's data.

Return value

A string representing the form element.

Related topics

12 theme calls to theme_form_element()
theme_checkbox in drupal-6.x/includes/form.inc
Format a checkbox.
theme_checkboxes in drupal-6.x/includes/form.inc
Format a set of checkboxes.
theme_date in drupal-6.x/includes/form.inc
Format a date selection element.
theme_file in drupal-6.x/includes/form.inc
Format a file upload field.
theme_item in drupal-6.x/includes/form.inc
Format a form item.

... See full list

File

drupal-6.x/includes/form.inc, line 2214

Code

function theme_form_element($element, $value) {
  // This is also used in the installer, pre-database setup.
  $t = get_t();

  $output = '<div class="form-item"';
  if (!empty($element['#id'])) {
    $output .= ' id="' . $element['#id'] . '-wrapper"';
  }
  $output .= ">\n";
  $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">*</span>' : '';

  if (!empty($element['#title'])) {
    $title = $element['#title'];
    if (!empty($element['#id'])) {
      $output .= ' <label for="' . $element['#id'] . '">' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n";
    }
    else {
      $output .= ' <label>' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n";
    }
  }

  $output .= " $value\n";

  if (!empty($element['#description'])) {
    $output .= ' <div class="description">' . $element['#description'] . "</div>\n";
  }

  $output .= "</div>\n";

  return $output;
}