Updated to Drupal 8.5. Core Media not yet in use.
[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  * @internal
13  */
14 class FormTestColorForm extends FormBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public function getFormId() {
20     return 'form_test_color';
21   }
22
23   /**
24    * {@inheritdoc}
25    */
26   public function buildForm(array $form, FormStateInterface $form_state) {
27     $form['color'] = [
28       '#type' => 'color',
29       '#title' => 'Color',
30     ];
31     $form['submit'] = [
32       '#type' => 'submit',
33       '#value' => 'Submit',
34     ];
35     return $form;
36   }
37
38   /**
39    * {@inheritdoc}
40    */
41   public function submitForm(array &$form, FormStateInterface $form_state) {
42     $form_state->setResponse(new JsonResponse($form_state->getValues()));
43   }
44
45 }