function theme_form_element


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
cis7 theme_form_element($variables)
cle7 theme_form_element($variables)
elmsmedia7 theme_form_element($variables)
icor7 theme_form_element($variables)
meedjum_blog7 theme_form_element($variables)
mooc7 theme_form_element($variables)

Returns HTML for a form element.

Each form element is wrapped in a DIV container having the following CSS classes:

  • form-item: Generic for all form elements.
  • form-type-#type: The internal element #type.
  • form-item-#name: The internal form element #name (usually derived from the $form structure and set via form_builder()).
  • form-disabled: Only set if the form element is #disabled.

In addition to the element itself, the DIV contains a label for the element based on the optional #title_display property, and an optional #description.

The optional #title_display property can have these values:

  • before: The label is output before the element. This is the default. The label includes the #title and the required marker, if #required.
  • after: The label is output after the element. For example, this is used for radio and checkbox #type elements as set in system_element_info(). If the #title is empty but the field is #required, the label will contain only the required marker.
  • invisible: Labels are critical for screen readers to enable them to properly navigate through forms but can be visually distracting. This property hides the label for everyone except screen readers.
  • attribute: Set the title attribute on the element to create a tooltip but output no label element. This is supported only for checkboxes and radios in form_pre_render_conditional_form_element(). It is used where a visual label is not needed, such as a table of checkboxes where the row and column provide the context. The tooltip will include the title and required marker.

If the #title property is not set, then the label and any required marker will not be output, regardless of the #title_display or #required values. This can be useful in cases such as the password_confirm element, which creates children elements that have their own labels and required markers, but the parent element should have neither. Use this carefully because a field without an associated label can cause accessibility challenges.


$variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #title, #title_display, #description, #id, #required, #children, #type, #name.

Related topics

11 theme calls to theme_form_element()
bef_checkbox in sites/all/modules/ulmus/better_exposed_filters/better_exposed_filters.theme
Build a BEF checkbox.
theme_date_popup in sites/all/modules/ulmus/date/date_popup/date_popup.module
Format a date popup element.
theme_date_select in sites/all/modules/ulmus/date/date_api/theme/
Returns HTML for a date select element.
theme_date_text in sites/all/modules/ulmus/date/date_api/theme/
Returns HTML for a date text element.
theme_date_timezone in sites/all/modules/ulmus/date/date_api/theme/
Returns HTML for a date timezone element.

... See full list

25 string references to the theme hook from theme_form_element()

Note: this list is generated by looking for the string for this theme hook, so it may include some references that are not actually using this theme hook.

bef_checkbox in sites/all/modules/ulmus/better_exposed_filters/better_exposed_filters.theme
Build a BEF checkbox.
date_repeat_form_element_radios_process in sites/all/modules/ulmus/date/date_repeat/date_repeat.module
Process function for 'date_repeat_form_element_radios'.
date_timezone_element_process in sites/all/modules/ulmus/date/date_api/
Creates a timezone form element.
devel_node_access_block_view in sites/all/modules/ulmus/devel/devel_node_access.module
Implements hook_block_view().
drupal_common_theme in includes/
Provides theme registration for themes across .inc files.

... See full list


includes/, line 4060
Functions for form and batch generation and processing.


function theme_form_element($variables) {
  $element = &$variables['element'];

  // This function is invoked as theme wrapper, but the rendered form element
  // may not necessarily have been processed by form_builder().
  $element += array(
    '#title_display' => 'before',

  // Add element #id for #type 'item'.
  if (isset($element['#markup']) && !empty($element['#id'])) {
    $attributes['id'] = $element['#id'];
  // Add element's #type and #name as class to aid with JS/CSS selectors.
  $attributes['class'] = array('form-item');
  if (!empty($element['#type'])) {
    $attributes['class'][] = 'form-type-' . strtr($element['#type'], '_', '-');
  if (!empty($element['#name'])) {
    $attributes['class'][] = 'form-item-' . strtr($element['#name'], array(' ' => '-', '_' => '-', '[' => '-', ']' => ''));
  // Add a class for disabled elements to facilitate cross-browser styling.
  if (!empty($element['#attributes']['disabled'])) {
    $attributes['class'][] = 'form-disabled';
  $output = '<div' . drupal_attributes($attributes) . '>' . "\n";

  // If #title is not set, we don't display any label or required marker.
  if (!isset($element['#title'])) {
    $element['#title_display'] = 'none';
  $prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . $element['#field_prefix'] . '</span> ' : '';
  $suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . $element['#field_suffix'] . '</span>' : '';

  switch ($element['#title_display']) {
    case 'before':
    case 'invisible':
      $output .= ' ' . theme('form_element_label', $variables);
      $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n";

    case 'after':
      $output .= ' ' . $prefix . $element['#children'] . $suffix;
      $output .= ' ' . theme('form_element_label', $variables) . "\n";

    case 'none':
    case 'attribute':
      // Output no label and no required marker, only the children.
      $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n";

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

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

  return $output;



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.