You are here

public static function ParagraphsWidget::allActionsAjax in Paragraphs 8

Ajax callback for all actions.

File

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

Class

ParagraphsWidget
Plugin implementation of the 'entity_reference_revisions paragraphs' widget.

Namespace

Drupal\paragraphs\Plugin\Field\FieldWidget

Code

public static function allActionsAjax(array $form, FormStateInterface $form_state) {
  $submit = ParagraphsWidget::getSubmitElementInfo($form, $form_state, ParagraphsWidget::ACTION_POSITION_HEADER);
  $element = $submit['element'];

  // Add a DIV around the delta receiving the Ajax effect.
  $delta = $submit['element']['#max_delta'];
  $element[$delta]['#prefix'] = '<div class="ajax-new-content">' . (isset($element[$delta]['#prefix']) ? $element[$delta]['#prefix'] : '');
  $element[$delta]['#suffix'] = (isset($element[$delta]['#suffix']) ? $element[$delta]['#suffix'] : '') . '</div>';
  return $element;
}