You are here

protected function LayoutParagraphsWidget::setUserInput in Layout Paragraphs 1.0.x

File

src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php, line 1405

Class

LayoutParagraphsWidget
Entity Reference with Layout field widget.

Namespace

Drupal\layout_paragraphs\Plugin\Field\FieldWidget

Code

protected function setUserInput(array $form, FormStateInterface &$form_state, int $delta, $element_name, $value) {
  $input = $form_state
    ->getUserInput();
  $parents = $form['#parents'];
  if (is_array($element_name)) {
    $element_path = array_merge($parents, [
      $this->fieldName,
      $delta,
    ], $element_name);
  }
  else {
    $element_path = array_merge($parents, [
      $this->fieldName,
      $delta,
      $element_name,
    ]);
  }
  NestedArray::setValue($input, $element_path, $value);
  $form_state
    ->setUserInput($input);
}