12a05e12d2b1b84f6c57222b71bde4c8bd98cd57
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / FormTestGroupDetailsForm.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 the #group property on #type 'details'.
10  *
11  * @internal
12  */
13 class FormTestGroupDetailsForm extends FormBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function getFormId() {
19     return 'form_test_group_details';
20   }
21
22   /**
23    * {@inheritdoc}
24    */
25   public function buildForm(array $form, FormStateInterface $form_state, $required = FALSE) {
26     $form['details'] = [
27       '#type' => 'details',
28       '#title' => 'Root element',
29       '#open' => TRUE,
30       '#required' => !empty($required),
31     ];
32     $form['meta'] = [
33       '#type' => 'details',
34       '#title' => 'Group element',
35       '#open' => TRUE,
36       '#group' => 'details',
37     ];
38     $form['meta']['element'] = [
39       '#type' => 'textfield',
40       '#title' => 'Nest in details element',
41     ];
42     return $form;
43   }
44
45   /**
46    * {@inheritdoc}
47    */
48   public function submitForm(array &$form, FormStateInterface $form_state) {
49   }
50
51 }