function ConfirmFormBase::buildForm

Same name in other branches
  1. 9 core/lib/Drupal/Core/Form/ConfirmFormBase.php \Drupal\Core\Form\ConfirmFormBase::buildForm()
  2. 10 core/lib/Drupal/Core/Form/ConfirmFormBase.php \Drupal\Core\Form\ConfirmFormBase::buildForm()
  3. 11.x core/lib/Drupal/Core/Form/ConfirmFormBase.php \Drupal\Core\Form\ConfirmFormBase::buildForm()

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

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