public ConfirmDeleteMultiple::buildForm(array $form, FormStateInterface $form_state)
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfirmFormBase::buildForm
File
- core/modules/comment/src/Form/ConfirmDeleteMultiple.php, line 81
Class
- ConfirmDeleteMultiple
- Provides the comment multiple delete confirmation form.
Namespace
Drupal\comment\Form
Code
public function buildForm(array $form, FormStateInterface $form_state) { $edit = $form_state->getUserInput(); $form['comments'] = array( '#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE, ); // array_filter() returns only elements with actual values. $comment_counter = 0; $this->comments = $this->commentStorage->loadMultiple(array_keys(array_filter($edit['comments']))); foreach ($this->comments as $comment) { $cid = $comment->id(); $form['comments'][$cid] = array( '#type' => 'hidden', '#value' => $cid, '#prefix' => '<li>', '#suffix' => Html::escape($comment->label()) . '</li>' ); $comment_counter++; } $form['operation'] = array('#type' => 'hidden', '#value' => 'delete'); if (!$comment_counter) { drupal_set_message($this->t('There do not appear to be any comments to delete, or your selected comment was deleted by another administrator.')); $form_state->setRedirect('comment.admin'); } return parent::buildForm($form, $form_state); }
Please login to continue.