You are here

function form_builder_webform_form_form_builder_preview_alter in Form Builder 7

Same name and namespace in other branches
  1. 7.2 modules/webform/form_builder_webform.module \form_builder_webform_form_form_builder_preview_alter()

Implements hook_form_FORM_ID_alter().

This form_alter is a workaround for an unfortunate interaction that ends up duplicating titles and descriptions for radios and checkboxes. By default, system.module defines a pre_render function for radios and checkboxes (form_pre_render_conditional_form_element). This pre_render adds the form_element theme_wrapper if there is a title or a description. Unfortunately, webform is already adding webform_element, which is nearly a copy of form_element, and if you have both, you get two titles and descriptions.

We can't use the normal mechanism for component alters, because that happens in a pre_render (so removing the other pre_render isn't going to help).

File

modules/webform/form_builder_webform.module, line 293
Form Builder integration for the Webform module.

Code

function form_builder_webform_form_form_builder_preview_alter(&$form, $form_state) {
  if ($form['#form_builder']['form_type'] != 'webform') {
    return;
  }
  $form['#attached']['css'][] = drupal_get_path('module', 'webform') . '/css/webform.css';
  _form_builder_remove_conditional_form_element_pre_render($form);
}