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 'url' elements.
14 class FormTestResponseForm extends FormBase {
19 public function getFormId() {
20 return 'form_test_response';
26 public function buildForm(array $form, FormStateInterface $form_state) {
28 '#type' => 'textfield',
29 '#title' => 'Content',
32 '#type' => 'textfield',
34 '#default_value' => 200,
46 public function submitForm(array &$form, FormStateInterface $form_state) {
47 $values = $form_state->getValues();
48 $form_state->setResponse(new JsonResponse($values['content'], (int) $values['status']));