summaryrefslogtreecommitdiffstats
path: root/core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php
blob: c5d4cef94d53673e64c323ad81d08e4f2cc07610 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php

namespace Drupal\form_test;

use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;

/**
 * Provides a test confirmation form.
 *
 * @internal
 */
class ConfirmFormTestForm extends ConfirmFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'form_test_confirm_test_form';
  }

  /**
   * {@inheritdoc}
   */
  public function getQuestion() {
    return $this->t('ConfirmFormTestForm::getQuestion().');
  }

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    return new Url('form_test.route8');
  }

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this->t('ConfirmFormTestForm::getDescription().');
  }

  /**
   * {@inheritdoc}
   */
  public function getConfirmText() {
    return $this->t('ConfirmFormTestForm::getConfirmText().');
  }

  /**
   * {@inheritdoc}
   */
  public function getCancelText() {
    return $this->t('ConfirmFormTestForm::getCancelText().');
  }

  /**
   * {@inheritdoc}
   */
  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);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    drupal_set_message($this->t('The ConfirmFormTestForm::submitForm() method was used for this form.'));
    $form_state->setRedirect('<front>');
  }

}