3 namespace Drupal\form_test\Form;
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
7 use Symfony\Component\HttpFoundation\JsonResponse;
10 * Form constructor for testing #type 'range' elements.
14 class FormTestRangeForm extends FormBase {
19 public function getFormId() {
20 return 'form_test_range';
26 public function buildForm(array $form, FormStateInterface $form_state) {
27 $form['with_default_value'] = [
29 '#title' => 'Range with default value',
33 '#default_value' => 18,
34 '#description' => 'The default value is 18.',
42 '#description' => 'Floating point number between 10 and 11.',
46 '#title' => 'Integer',
50 '#description' => 'Even integer between 2 and 8.',
57 '#description' => 'Value between 2.9 and 10.9.',
69 public function submitForm(array &$form, FormStateInterface $form_state) {
70 $form_state->setResponse(new JsonResponse($form_state->getValues()));