3 namespace Drupal\form_test\Form;
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
7 use Symfony\Component\HttpFoundation\JsonResponse;
9 class FormTestInputForgeryForm extends FormBase {
14 public function getFormId() {
15 return '_form_test_input_forgery';
21 public function buildForm(array $form, FormStateInterface $form_state) {
22 // For testing that a user can't submit a value not matching one of the
24 $form['checkboxes'] = [
25 '#title' => t('Checkboxes'),
26 '#type' => 'checkboxes',
34 '#value' => t('Submit'),
43 public function submitForm(array &$form, FormStateInterface $form_state) {
44 return new JsonResponse($form_state->getValues());