Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / system / tests / modules / test_page_test / src / Form / TestForm.php
1 <?php
2
3 namespace Drupal\test_page_test\Form;
4
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Defines a test form for testing assertions.
10  */
11 class TestForm extends FormBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function buildForm(array $form, FormStateInterface $form_state) {
17     $form['test_table'] = [
18       '#type' => 'table',
19       '#header' => ['Column 1', 'Column 2', 'Column 3'],
20       'row_1' => [
21         'col_1' => ['#plain_text' => 'foo'],
22         'col_2' => ['#plain_text' => 'bar'],
23         'col_3' => ['#plain_text' => 'baz'],
24       ],
25       'row_2' => [
26         'col_1' => ['#plain_text' => 'one'],
27         'col_2' => ['#plain_text' => 'two'],
28         'col_3' => ['#plain_text' => 'three'],
29       ],
30     ];
31
32     $form['name'] = [
33       '#type' => 'textfield',
34       '#title' => 'Name',
35       '#default_value' => 'Test name',
36     ];
37
38     $form['checkbox_enabled'] = [
39       '#type' => 'checkbox',
40       '#title' => 'Checkbox enabled',
41       '#default_value' => TRUE,
42     ];
43
44     $form['checkbox_disabled'] = [
45       '#type' => 'checkbox',
46       '#title' => 'Checkbox disabled',
47       '#default_value' => FALSE,
48     ];
49
50     $form['description'] = [
51       '#type' => 'textfield',
52       '#title' => 'Description',
53       '#default_value' => '',
54     ];
55
56     $form['options'] = [
57       '#type' => 'select',
58       '#title' => 'Options',
59       '#options' => [
60         1 => 'one',
61         2 => 'two',
62         3 => 'three',
63       ],
64       '#default_value' => 2,
65     ];
66
67     $form['duplicate_button'] = [
68       '#type' => 'submit',
69       '#name' => 'duplicate_button',
70       '#value' => 'Duplicate button 1',
71     ];
72
73     $form['duplicate_button_2'] = [
74       '#type' => 'submit',
75       '#name' => 'duplicate_button',
76       '#value' => 'Duplicate button 2',
77     ];
78
79     $form['test_textarea_with_newline'] = [
80       '#type' => 'textarea',
81       '#title' => 'Textarea with newline',
82       '#default_value' => "Test text with\nnewline",
83     ];
84
85     $form['save'] = [
86       '#type' => 'submit',
87       '#value' => $this->t('Save'),
88     ];
89
90     return $form;
91   }
92
93   /**
94    * {@inheritdoc}
95    */
96   public function getFormId() {
97     return 'test_page_form';
98   }
99
100   /**
101    * {@inheritdoc}
102    */
103   public function submitForm(array &$form, FormStateInterface $form_state) {
104     // Empty on purpose, we just want to test the rendered form elements.
105   }
106
107 }