function NodePreviewForm::submitForm

Same name in other branches
  1. 8.9.x core/modules/node/src/Form/NodePreviewForm.php \Drupal\node\Form\NodePreviewForm::submitForm()
  2. 10 core/modules/node/src/Form/NodePreviewForm.php \Drupal\node\Form\NodePreviewForm::submitForm()
  3. 11.x core/modules/node/src/Form/NodePreviewForm.php \Drupal\node\Form\NodePreviewForm::submitForm()

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.