Version 1
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / FormTestDetailsForm.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 'container'.
10  */
11 class FormTestDetailsForm extends FormBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function getFormId() {
17     return 'form_test_details_form';
18   }
19
20   /**
21    * {@inheritdoc}
22    */
23   public function buildForm(array $form, FormStateInterface $form_state) {
24     $form['meta'] = [
25       '#type' => 'details',
26       '#title' => 'Details element',
27       '#open' => TRUE,
28     ];
29     $form['submit'] = ['#type' => 'submit', '#value' => 'Submit'];
30     return $form;
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function validateForm(array &$form, FormStateInterface $form_state) {
37     $form_state->setErrorByName('meta', 'I am an error on the details element.');
38   }
39
40   /**
41    * {@inheritdoc}
42    */
43   public function submitForm(array &$form, FormStateInterface $form_state) {
44   }
45
46 }