You are here

function ife_alter_form_element in Inline Form Errors 7

Same name and namespace in other branches
  1. 6.2 ife.module \ife_alter_form_element()
  2. 6 ife.module \ife_alter_form_element()

Function to add our custom theme to the element

1 call to ife_alter_form_element()
ife_filter_form in ./ife.module
Function to recursivly go through a form and alter all valid field type elements

File

./ife.module, line 244
Drupal hooks

Code

function ife_alter_form_element(&$element, $display) {

  // Adding any theme wrappers here will mean the default ones don't get added-
  // so we get the default ones and add them first.
  $defaults = element_info_property($element['#type'], '#theme_wrappers');
  if (empty($element['#theme_wrappers']) && !empty($defaults)) {
    $element['#theme_wrappers'] = $defaults;
  }
  $element['#theme_wrappers'][] = 'ife_form_element';

  //resend the element type, drupal sets the #type marker to markup
  $element['#field_type'] = $element['#type'];

  //add display type to element to avoid extra queries
  $element['#display_type'] = $display;

  // These elements need special attention. Make sure that default pre-render
  // functions are included.
  switch ($element['#type']) {
    case 'text_format':
    case 'date_popup':
    case 'date_select':
    case 'date_text':
      $defaults = element_info_property($element['#type'], '#pre_render', array());
      if (empty($element['#pre_render'])) {
        $element['#pre_render'] = $defaults;
      }
      $element['#pre_render'] = array_merge($element['#pre_render'], array(
        'ife_text_format_prerender',
      ));
      break;
  }
}