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.
12 class FormTestResponseForm extends FormBase {
17 public function getFormId() {
18 return 'form_test_response';
24 public function buildForm(array $form, FormStateInterface $form_state) {
26 '#type' => 'textfield',
27 '#title' => 'Content',
30 '#type' => 'textfield',
32 '#default_value' => 200,
44 public function submitForm(array &$form, FormStateInterface $form_state) {
45 $values = $form_state->getValues();
46 $form_state->setResponse(new JsonResponse($values['content'], (int) $values['status']));