public static function ComponentSectionForm::variantElementAjax in Module Builder 8.3
Ajax callback for the variant elements.
This returns the new page content to replace the page content made obsolete by the form submission.
File
- src/
Form/ ComponentSectionForm.php, line 843
Class
- ComponentSectionForm
- Generic form for entering a section of data for a component.
Namespace
Drupal\module_builder\FormCode
public static function variantElementAjax(array $form, FormStateInterface $form_state) {
$variant_element = $form_state
->getTriggeringElement();
// Go up in the form, to the widgets container.
$variant_element_array_parents = $variant_element['#array_parents'];
// Get the address of the containing multiple data item.
// WARNING: this assumes the 'data' form element is at the top in the
// form structure!
if ($variant_element['#type'] == 'radios') {
$widgets_container_parents = array_slice($variant_element_array_parents, 0, -2);
}
elseif ($variant_element['#type'] == 'select') {
$widgets_container_parents = array_slice($variant_element_array_parents, 0, -1);
}
$element = NestedArray::getValue($form, $widgets_container_parents);
return $element;
}