FormTestInputForgeryForm.php in Zircon Profile 8.0
File
core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php
View source
<?php
namespace Drupal\form_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
class FormTestInputForgeryForm extends FormBase {
public function getFormId() {
return '_form_test_input_forgery';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['checkboxes'] = array(
'#title' => t('Checkboxes'),
'#type' => 'checkboxes',
'#options' => array(
'one' => 'One',
'two' => 'Two',
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
return new JsonResponse($form_state
->getValues());
}
}