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.
12 class FormTestRangeForm extends FormBase {
17 public function getFormId() {
18 return 'form_test_range';
24 public function buildForm(array $form, FormStateInterface $form_state) {
25 $form['with_default_value'] = [
27 '#title' => 'Range with default value',
31 '#default_value' => 18,
32 '#description' => 'The default value is 18.',
40 '#description' => 'Floating point number between 10 and 11.',
44 '#title' => 'Integer',
48 '#description' => 'Even integer between 2 and 8.',
55 '#description' => 'Value between 2.9 and 10.9.',
67 public function submitForm(array &$form, FormStateInterface $form_state) {
68 $form_state->setResponse(new JsonResponse($form_state->getValues()));