public function Form::addComponents in Form Builder 7.2
Add components to the form.
Parameters
array $components: A components array as you would find it in $node->webform['components'].
File
- modules/
webform/ src/ Form.php, line 59
Class
Namespace
Drupal\form_builder_webformCode
public function addComponents($components) {
foreach ($components as $cid => $component) {
$element['#webform_component'] = $component;
$element['#weight'] = $component['weight'];
$element['#key'] = $component['form_key'];
$parent_id = $component['pid'] ? 'cid_' . $component['pid'] : FORM_BUILDER_ROOT;
$element['#form_builder'] = array(
'element_id' => 'cid_' . $cid,
'parent_id' => $parent_id,
);
if ($map = _form_builder_webform_property_map($component['type'])) {
// Keep the internal type of this element as the component type. For example
// this may match an $element['#type'] of 'webform_date' and set the
// $element['#form_builder']['element_type'] to simply 'date'.
if (isset($map['form_builder_type'])) {
$element['#form_builder']['element_type'] = $map['form_builder_type'];
}
}
if ($e = form_builder_webform_component_invoke($component['type'], 'form_builder_load', $element)) {
$element = $e;
}
$this
->setElementArray($element, $parent_id);
}
}