public static function ParagraphsWidget::setSetSubmit in Paragraphs Sets 8
File
- src/
Plugin/ Field/ FieldWidget/ ParagraphsWidget.php, line 473
Class
- ParagraphsWidget
- Plugin implementation of 'entity_reference_revisions paragraphs sets' widget.
Namespace
Drupal\paragraphs_sets\Plugin\Field\FieldWidgetCode
public static function setSetSubmit(array $form, FormStateInterface $form_state) {
$button = $form_state
->getTriggeringElement();
// Go one level up in the form, to the widgets container.
$element = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -2));
$field_name = $element['#field_name'];
$parents = $element['#field_parents'];
$button_type = end($button['#array_parents']);
// Increment the items count.
$widget_state = static::getWidgetState($parents, $field_name, $form_state);
$widget_state['button_type'] = $button_type;
if (isset($button['#set_machine_name'])) {
$widget_state['selected_set'] = $button['#set_machine_name'];
}
else {
$widget_state['selected_set'] = $element['set_selection']['set_selection_select']['#value'];
}
static::setWidgetState($parents, $field_name, $form_state, $widget_state);
$form_state
->setRebuild();
}