class ConfirmFormBase
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Form/ConfirmFormBase.php \Drupal\Core\Form\ConfirmFormBase
- 9 core/lib/Drupal/Core/Form/ConfirmFormBase.php \Drupal\Core\Form\ConfirmFormBase
- 10 core/lib/Drupal/Core/Form/ConfirmFormBase.php \Drupal\Core\Form\ConfirmFormBase
Provides an generic base class for a confirmation form.
Hierarchy
- class \Drupal\Core\Form\FormBase extends \Drupal\Core\Form\FormInterface, \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Routing\LinkGeneratorTrait, \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\Routing\UrlGeneratorTrait
- class \Drupal\Core\Form\ConfirmFormBase extends \Drupal\Core\Form\ConfirmFormInterface implements \Drupal\Core\Form\FormBase
Expanded class hierarchy of ConfirmFormBase
29 files declare their use of ConfirmFormBase
- BanDelete.php in core/
modules/ ban/ src/ Form/ BanDelete.php - BookRemoveForm.php in core/
modules/ book/ src/ Form/ BookRemoveForm.php - ConfigSingleImportForm.php in core/
modules/ config/ src/ Form/ ConfigSingleImportForm.php - ConfigTranslationDeleteForm.php in core/
modules/ config_translation/ src/ Form/ ConfigTranslationDeleteForm.php - ConfirmFormTestForm.php in core/
modules/ system/ tests/ modules/ form_test/ src/ ConfirmFormTestForm.php
File
-
core/
lib/ Drupal/ Core/ Form/ ConfirmFormBase.php, line 8
Namespace
Drupal\Core\FormView source
abstract class ConfirmFormBase extends FormBase implements ConfirmFormInterface {
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->t('This action cannot be undone.');
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Confirm');
}
/**
* {@inheritdoc}
*/
public function getCancelText() {
return $this->t('Cancel');
}
/**
* {@inheritdoc}
*/
public function getFormName() {
return 'confirm';
}
/**
* {@inheritdoc}
*/
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.