Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / JavascriptStatesForm.php
1 <?php
2
3 namespace Drupal\form_test\Form;
4
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Builds a simple form to test states.
10  *
11  * @see \Drupal\FunctionalJavascriptTests\Core\Form\JavascriptStatesTest
12  */
13 class JavascriptStatesForm extends FormBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function getFormId() {
19     return 'javascript_states_form';
20   }
21
22   /**
23    * {@inheritdoc}
24    */
25   public function buildForm(array $form, FormStateInterface $form_state) {
26     $form['select'] = [
27       '#type' => 'select',
28       '#title' => 'select 1',
29       '#options' => [0 => 0, 1 => 1, 2 => 2],
30     ];
31     $form['number'] = [
32       '#type' => 'number',
33       '#title' => 'enter 1',
34     ];
35     $form['textfield'] = [
36       '#type' => 'textfield',
37       '#title' => 'textfield',
38       '#states' => [
39         'visible' => [
40           [':input[name="select"]' => ['value' => '1']],
41           'or',
42           [':input[name="number"]' => ['value' => '1']],
43         ],
44       ],
45     ];
46     return $form;
47   }
48
49   /**
50    * {@inheritdoc}
51    */
52   public function submitForm(array &$form, FormStateInterface $form_state) {
53   }
54
55 }