You are here

public function ConfirmFormBase::buildForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Form/ConfirmFormBase.php \Drupal\Core\Form\ConfirmFormBase::buildForm()

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 FormInterface::buildForm

25 calls to ConfirmFormBase::buildForm()
BanDelete::buildForm in core/modules/ban/src/Form/BanDelete.php
BookRemoveForm::buildForm in core/modules/book/src/Form/BookRemoveForm.php
Form constructor.
ConfigSingleImportForm::buildForm in core/modules/config/src/Form/ConfigSingleImportForm.php
Form constructor.
ConfigTranslationDeleteForm::buildForm in core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php
Form constructor.
ConfirmFormTestForm::buildForm in core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php
Form constructor.

... See full list

25 methods override ConfirmFormBase::buildForm()
BanDelete::buildForm in core/modules/ban/src/Form/BanDelete.php
BookRemoveForm::buildForm in core/modules/book/src/Form/BookRemoveForm.php
Form constructor.
ConfigSingleImportForm::buildForm in core/modules/config/src/Form/ConfigSingleImportForm.php
Form constructor.
ConfigTranslationDeleteForm::buildForm in core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php
Form constructor.
ConfirmFormTestForm::buildForm in core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php
Form constructor.

... See full list

File

core/lib/Drupal/Core/Form/ConfirmFormBase.php, line 41

Class

ConfirmFormBase
Provides a generic base class for a confirmation form.

Namespace

Drupal\Core\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['#title'] = $this
    ->getQuestion();
  $form['#attributes']['class'][] = 'confirmation';
  $form['description'] = [
    '#markup' => $this
      ->getDescription(),
  ];
  $form[$this
    ->getFormName()] = [
    '#type' => 'hidden',
    '#value' => 1,
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->getConfirmText(),
    '#button_type' => 'primary',
  ];
  $form['actions']['cancel'] = ConfirmFormHelper::buildCancelLink($this, $this
    ->getRequest());

  // By default, render the form using theme_confirm_form().
  if (!isset($form['#theme'])) {
    $form['#theme'] = 'confirm_form';
  }
  return $form;
}