You are here

function webform_pre_render_remove_id in Webform 7.4

A Form API #pre_render function that removes the ID from an element.

Drupal forcibly adds IDs to all form elements, including those that do not need them for any reason, such as the actions wrapper or submit buttons. We use this process function wherever we wish to remove an ID from an element. Because #states and #ajax require IDs, they are only removed if the states and ajax arrays are empty.

1 string reference to 'webform_pre_render_remove_id'
webform_client_form in ./webform.module
Client form generation function.

File

./webform.module, line 3671
This module provides a simple way to create forms and questionnaires.

Code

function webform_pre_render_remove_id($element) {
  if (empty($element['#states']) && empty($element['#ajax'])) {
    $element['#id'] = NULL;

    // Removing array parents is required to prevent theme_container from adding
    // an empty ID attribute.
    $element['#array_parents'] = NULL;
  }
  return $element;
}