ConfirmFormTestForm.php in Drupal 10
File
core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php
View source
<?php
namespace Drupal\form_test;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class ConfirmFormTestForm extends ConfirmFormBase {
public function getFormId() {
return 'form_test_confirm_test_form';
}
public function getQuestion() {
return $this
->t('ConfirmFormTestForm::getQuestion().');
}
public function getCancelUrl() {
return new Url('form_test.route8');
}
public function getDescription() {
return $this
->t('ConfirmFormTestForm::getDescription().');
}
public function getConfirmText() {
return $this
->t('ConfirmFormTestForm::getConfirmText().');
}
public function getCancelText() {
return $this
->t('ConfirmFormTestForm::getCancelText().');
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['element'] = [
'#markup' => '<p>The ConfirmFormTestForm::buildForm() method was used for this form.</p>',
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->messenger()
->addStatus($this
->t('The ConfirmFormTestForm::submitForm() method was used for this form.'));
$form_state
->setRedirect('<front>');
}
}