You are here

function _form_builder_webform_build_edit_form in Form Builder 7

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

Helper function; builds a form for editing part of a webform component.

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

Parameters

$component_type: The webform component type to be edited.

$element: A form array representing the element whose configuration form we are building.

$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 "#".

$form_builder_property_group: The Form Builder property group in which this configuration form should be displayed.

$form_nested_keys: 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, if the part of the configuration form we are interested in is located in $form['display']['width'], where $form is the output of _webform_edit_[component](), we would pass array('display', 'width') in for this parameter.

$component_nested_keys: An array of nested keys representing the location of the portions of the webform component that this form is responsible for configuring. For example, if this form configures the data that is stored in $component['extra']['filtering'], where $component has the structure of the array returned by _webform_defaults_[component](), we would pass array('extra', 'filtering') in for this parameter.

Return value

A form array that can be used to edit the specified part of the webform component represented by $element.

3 calls to _form_builder_webform_build_edit_form()
form_builder_webform_property_grid_options_form in modules/webform/form_builder_webform.components.inc
Configuration form for the "grid_options" property.
form_builder_webform_property_grid_questions_form in modules/webform/form_builder_webform.components.inc
Configuration form for the "grid_questions" property.
_form_builder_webform_mapped_form in modules/webform/form_builder_webform.components.inc
Helper function; Generate a configuration form based on a map.

File

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

Code

function _form_builder_webform_build_edit_form($component_type, $element, $property, $form_builder_property_group, $form_nested_keys) {
  module_load_include('inc', 'webform', 'includes/webform.components');

  // The Webform module stores existing component data as part of the passed-in
  // element. If the component doesn't exist yet, initialize a default
  // component.
  $defaults_function = '_webform_defaults_' . $component_type;
  $component = isset($element['#webform_component']) ? $element['#webform_component'] : $defaults_function();
  $nid = isset($component['nid']) ? $component['nid'] : NULL;

  // Build the entire _webform_edit_file() form based on the current state of
  // the component, and obtain the slice of it that we want.
  $empty_form = array();
  $empty_form_state = form_state_defaults();

  // The full node is needed here so that the "private" option can be access
  // checked.
  $node = !isset($nid) ? (object) array(
    'nid' => NULL,
    'webform' => webform_node_defaults(),
  ) : node_load($nid);
  $form = webform_component_edit_form($empty_form, $empty_form_state, $node, $component);
  $form = drupal_array_get_nested_value($form, $form_nested_keys);

  // 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 ($form_builder_property_group) {
    $form['#form_builder']['property_group'] = $form_builder_property_group;
  }

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