function NodeForm::preview
Same name in other branches
- 8.9.x core/modules/node/src/NodeForm.php \Drupal\node\NodeForm::preview()
- 10 core/modules/node/src/NodeForm.php \Drupal\node\NodeForm::preview()
- 11.x core/modules/node/src/NodeForm.php \Drupal\node\NodeForm::preview()
Form submission handler for the 'preview' action.
Parameters
$form: An associative array containing the structure of the form.
$form_state: The current state of the form.
File
-
core/
modules/ node/ src/ NodeForm.php, line 245
Class
- NodeForm
- Form handler for the node edit forms.
Namespace
Drupal\nodeCode
public function preview(array $form, FormStateInterface $form_state) {
$store = $this->tempStoreFactory
->get('node_preview');
$this->entity->in_preview = TRUE;
$store->set($this->entity
->uuid(), $form_state);
$route_parameters = [
'node_preview' => $this->entity
->uuid(),
'view_mode_id' => 'full',
];
$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.