public static function ComponentSectionForm::updateVariantSubmit in Module Builder 8.3
Submission handler for the "Update variants" buttons.
File
- src/
Form/ ComponentSectionForm.php, line 791
Class
- ComponentSectionForm
- Generic form for entering a section of data for a component.
Namespace
Drupal\module_builder\FormCode
public static function updateVariantSubmit(array $form, FormStateInterface $form_state) {
$button = $form_state
->getTriggeringElement();
// dsm($button);
// Get the value of the mutable data variant property.
$values_address = array_slice($button['#parents'], 0, -1);
$values_address[] = $button['#variant_data_name'];
// Get the containing variant data item, using the address set in the
// button.
$data = $form_state
->get('data');
$variant_data_item = $data
->getItem($button['#data_address']);
$values = $form_state
->getValues();
$variant_value = NestedArray::getValue($values, $values_address);
$variant_data_item->value = $variant_value;
$form_state
->set('data', $data);
// dsm($data);
$form_state
->setRebuild();
}