public static function ParagraphsWidget::dragDropModeSubmit

Sets the form mode accordingly.

Parameters

array $form: An associate array containing the structure of the form.

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

File

paragraphs/src/Plugin/Field/FieldWidget/ParagraphsWidget.php, line 2242

Class

ParagraphsWidget
Plugin implementation of the 'entity_reference_revisions paragraphs' widget.

Namespace

Drupal\paragraphs\Plugin\Field\FieldWidget

Code

public static function dragDropModeSubmit(array $form, FormStateInterface $form_state) {
  $submit = ParagraphsWidget::getSubmitElementInfo($form, $form_state, ParagraphsWidget::ACTION_POSITION_HEADER);
  if (empty($submit['widget_state']['dragdrop'])) {
    $submit['widget_state']['dragdrop'] = TRUE;
  }
  else {
    $submit['widget_state']['dragdrop'] = FALSE;
  }

  // Make sure that flag that we already reordered is unset when the mode is
  // switched.
  unset($submit['widget_state']['reordered']);

  // Switch the form mode accordingly.
  static::setWidgetState($submit['parents'], $submit['field_name'], $form_state, $submit['widget_state']);
  $form_state
    ->setRebuild();
}