public static function InlineParagraphsWidget::paragraphsItemSubmit in Paragraphs 8
File
- src/
Plugin/ Field/ FieldWidget/ InlineParagraphsWidget.php, line 1183
Class
- InlineParagraphsWidget
- Plugin implementation of the 'entity_reference paragraphs' widget.
Namespace
Drupal\paragraphs\Plugin\Field\FieldWidgetCode
public static function paragraphsItemSubmit(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, -4));
$delta = array_slice($button['#array_parents'], -4, -3);
$delta = $delta[0];
$field_name = $element['#field_name'];
$parents = $element['#field_parents'];
$widget_state = static::getWidgetState($parents, $field_name, $form_state);
$widget_state['paragraphs'][$delta]['mode'] = $button['#paragraphs_mode'];
if (!empty($button['#paragraphs_show_warning'])) {
$widget_state['paragraphs'][$delta]['show_warning'] = $button['#paragraphs_show_warning'];
}
static::setWidgetState($parents, $field_name, $form_state, $widget_state);
$form_state
->setRebuild();
}