07638809e352657e07ab7806fe6bebca9fbecf5b
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / FormTestColorForm.php
1 <?php
2
3 namespace Drupal\form_test\Form;
4
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
7 use Symfony\Component\HttpFoundation\JsonResponse;
8
9 /**
10  * Form constructor for testing #type 'color' elements.
11  */
12 class FormTestColorForm extends FormBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public function getFormId() {
18     return 'form_test_color';
19   }
20
21   /**
22    * {@inheritdoc}
23    */
24   public function buildForm(array $form, FormStateInterface $form_state) {
25     $form['color'] = [
26       '#type' => 'color',
27       '#title' => 'Color',
28     ];
29     $form['submit'] = [
30       '#type' => 'submit',
31       '#value' => 'Submit',
32     ];
33     return $form;
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   public function submitForm(array &$form, FormStateInterface $form_state) {
40     $form_state->setResponse(new JsonResponse($form_state->getValues()));
41   }
42
43 }