You are here

function _form_builder_webform_mapped_form in Form Builder 7.2

Same name and namespace in other branches
  1. 6 modules/webform/form_builder_webform.components.inc \_form_builder_webform_mapped_form()
  2. 7 modules/webform/form_builder_webform.components.inc \_form_builder_webform_mapped_form()

Helper function; Generate a configuration form based on a map.

The returned form is derived from a subcomponent of the component form provided by the Webform module.

Parameters

$component: The webform component to be edited.

$edit: The webform component edit form as produced by webform itself.

$property: The property of $element which stores the state of portions of the webform component that this form is responsible for configuring. The property should be passed in without the leading "#".

array $map: The mapping data for this webform component. Including:

  • form_parents: An array of nested keys representing the location of the subcomponent of the _webform_edit_[component]() form that this configuration form will be taken from. For example ['display', 'with'] to get $form['display']['with'] fromm _webform_edit_[component]().
  • property_group: Controls in which tab of the configuration form the property will be shown.
  • weight: Override the #weight of the property form element.

Return value

array Part of the webform component edit form as specified in `$map['form_parents']` prepared for being used in a form_builder configure form.

1 string reference to '_form_builder_webform_mapped_form'
form_builder_webform_form_builder_properties in modules/webform/form_builder_webform.module
Implements hook_form_builder_properties().

File

modules/webform/form_builder_webform.components.inc, line 989
Default webform component callbacks for functionality related to the Form Builder.

Code

function _form_builder_webform_mapped_form($component, $edit, &$form_state, $property) {
  if (!(($component_type = $component['type']) && ($map = _form_builder_webform_property_map($component_type)))) {
    return [];
  }
  $map = $map['properties'][$property];
  $map += [
    'property_group' => reset($map['form_parents']),
  ];
  $form = drupal_array_get_nested_value($edit, $map['form_parents']);

  // Force the form to have a consistent #tree structure so it will appear in
  // $form_state['values'] the way we want.
  _form_builder_webform_force_tree($form);

  // Indicate the Form Builder property group that this form will be displayed
  // in.
  if (!empty($map['property_group'])) {
    $form['#form_builder']['property_group'] = $map['property_group'];
  }

  // Allow overriding the weight via the map.
  if (isset($map['weight'])) {
    $form['#weight'] = $map['weight'];
  }

  // Return the form, keyed by the name of the property that is being
  // configured.
  return [
    $property => $form,
  ];
}