You are here

public function ParagraphsWidget::extractFormValues in Paragraphs 8

Extracts field values from submitted form values.

Parameters

\Drupal\Core\Field\FieldItemListInterface $items: The field values. This parameter is altered by reference to receive the incoming form values.

array $form: The form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Overrides WidgetBase::extractFormValues

File

src/Plugin/Field/FieldWidget/ParagraphsWidget.php, line 2330

Class

ParagraphsWidget
Plugin implementation of the 'entity_reference_revisions paragraphs' widget.

Namespace

Drupal\paragraphs\Plugin\Field\FieldWidget

Code

public function extractFormValues(FieldItemListInterface $items, array $form, FormStateInterface $form_state) {

  // Filter possible empty items.
  $items
    ->filterEmptyItems();

  // Remove buttons from header actions.
  $field_name = $this->fieldDefinition
    ->getName();
  $path = array_merge($form['#parents'], array(
    $field_name,
  ));
  $form_state_variables = $form_state
    ->getValues();
  $key_exists = NULL;
  $values = NestedArray::getValue($form_state_variables, $path, $key_exists);
  if ($key_exists) {
    unset($values['header_actions']);
    NestedArray::setValue($form_state_variables, $path, $values);
    $form_state
      ->setValues($form_state_variables);
  }
  return parent::extractFormValues($items, $form, $form_state);
}