Updated to Drupal 8.6.4, which is PHP 7.3 friendly. Also updated HTMLaw library....
[yaffs-website] / web / core / modules / filter / tests / filter_test / src / Form / FilterTestFormatForm.php
1 <?php
2
3 namespace Drupal\filter_test\Form;
4
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Shows a test form for testing the 'text_format' form element.
10  *
11  * @internal
12  */
13 class FilterTestFormatForm extends FormBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function getFormId() {
19     return 'filter_test_format_form';
20   }
21
22   /**
23    * {@inheritdoc}
24    */
25   public function buildForm(array $form, FormStateInterface $form_state) {
26     // This ensures that the parent array key makes it into the HTML ID of the
27     // form elements.
28     $form['#tree'] = TRUE;
29
30     $form['all_formats'] = [
31       '#type' => 'details',
32       '#title' => 'All text formats',
33     ];
34     $form['all_formats']['no_default'] = [
35       '#type' => 'text_format',
36       '#title' => 'No default value',
37     ];
38     $form['all_formats']['default'] = [
39       '#type' => 'text_format',
40       '#title' => 'Default value',
41       '#format' => 'filter_test',
42     ];
43     $form['all_formats']['default_missing'] = [
44       '#type' => 'text_format',
45       '#title' => 'Missing default value',
46       '#format' => 'missing_format',
47     ];
48
49     $form['restricted_formats'] = [
50       '#type' => 'details',
51       '#title' => 'Restricted text format list',
52     ];
53     $form['restricted_formats']['no_default'] = [
54       '#type' => 'text_format',
55       '#title' => 'No default value',
56       '#allowed_formats' => ['full_html', 'filter_test'],
57     ];
58     $form['restricted_formats']['default'] = [
59       '#type' => 'text_format',
60       '#title' => 'Default value',
61       '#format' => 'full_html',
62       '#allowed_formats' => ['full_html', 'filter_test'],
63     ];
64     $form['restricted_formats']['default_missing'] = [
65       '#type' => 'text_format',
66       '#title' => 'Missing default value',
67       '#format' => 'missing_format',
68       '#allowed_formats' => ['full_html', 'filter_test'],
69     ];
70     $form['restricted_formats']['default_disallowed'] = [
71       '#type' => 'text_format',
72       '#title' => 'Disallowed default value',
73       '#format' => 'filtered_html',
74       '#allowed_formats' => ['full_html', 'filter_test'],
75     ];
76
77     $form['single_format'] = [
78       '#type' => 'details',
79       '#title' => 'Single text format',
80     ];
81     $form['single_format']['no_default'] = [
82       '#type' => 'text_format',
83       '#title' => 'No default value',
84       '#allowed_formats' => ['filter_test'],
85     ];
86     $form['single_format']['default'] = [
87       '#type' => 'text_format',
88       '#title' => 'Default value',
89       '#format' => 'filter_test',
90       '#allowed_formats' => ['filter_test'],
91     ];
92     $form['single_format']['default_missing'] = [
93       '#type' => 'text_format',
94       '#title' => 'Missing default value',
95       '#format' => 'missing_format',
96       '#allowed_formats' => ['filter_test'],
97     ];
98     $form['single_format']['default_disallowed'] = [
99       '#type' => 'text_format',
100       '#title' => 'Disallowed default value',
101       '#format' => 'full_html',
102       '#allowed_formats' => ['filter_test'],
103     ];
104
105     return $form;
106   }
107
108   /**
109    * {@inheritdoc}
110    */
111   public function submitForm(array &$form, FormStateInterface $form_state) {
112   }
113
114 }