You are here

public function NodePreviewForm::submitForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/node/src/Form/NodePreviewForm.php \Drupal\node\Form\NodePreviewForm::submitForm()

Form submission handler.

Parameters

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

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

Overrides FormInterface::submitForm

File

core/modules/node/src/Form/NodePreviewForm.php, line 130

Class

NodePreviewForm
Contains a form for switching the view mode of a node during preview.

Namespace

Drupal\node\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $route_parameters = [
    'node_preview' => $form_state
      ->getValue('uuid'),
    'view_mode_id' => $form_state
      ->getValue('view_mode'),
  ];
  $options = [];
  $query = $this
    ->getRequest()->query;
  if ($query
    ->has('destination')) {
    $options['query']['destination'] = $query
      ->get('destination');
    $query
      ->remove('destination');
  }
  $form_state
    ->setRedirect('entity.node.preview', $route_parameters, $options);
}