public static function InlineParagraphsWidget::itemAjax

File

paragraphs/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php, line 1219

Class

InlineParagraphsWidget
Plugin implementation of the 'entity_reference paragraphs' widget.

Namespace

Drupal\paragraphs\Plugin\Field\FieldWidget

Code

public static function itemAjax(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));
  $element['#prefix'] = '<div class="ajax-new-content">' . (isset($element['#prefix']) ? $element['#prefix'] : '');
  $element['#suffix'] = (isset($element['#suffix']) ? $element['#suffix'] : '') . '</div>';
  return $element;
}