function CommentForm::preview

Same name and namespace in other branches
  1. 9 core/modules/comment/src/CommentForm.php \Drupal\comment\CommentForm::preview()
  2. 8.9.x core/modules/comment/src/CommentForm.php \Drupal\comment\CommentForm::preview()
  3. 10 core/modules/comment/src/CommentForm.php \Drupal\comment\CommentForm::preview()

Form submission handler for the 'preview' action.

Parameters

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

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

File

core/modules/comment/src/CommentForm.php, line 370

Class

CommentForm
Base handler for comment forms.

Namespace

Drupal\comment

Code

public function preview(array &$form, FormStateInterface $form_state) {
    $comment_preview = comment_preview($this->entity, $form_state);
    $comment_preview['#title'] = $this->t('Preview comment');
    $form_state->set('comment_preview', $comment_preview);
    $form_state->setRebuild();
}

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