3 namespace Drupal\ajax_test\Form;
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 * Dummy form for testing DialogRenderer with _form routes.
13 class AjaxTestForm extends FormBase {
18 public function getFormId() {
19 return 'ajax_test_form';
25 public function buildForm(array $form, FormStateInterface $form_state) {
27 $form['#action'] = \Drupal::url('ajax_test.dialog');
29 $form['description'] = [
30 '#markup' => '<p>' . $this->t("Ajax Form contents description.") . '</p>',
36 $form['actions']['submit'] = [
38 '#value' => $this->t('Do it'),
40 $form['actions']['preview'] = [
42 '#value' => $this->t('Preview'),
43 // No regular submit-handler. This form only works via JavaScript.
46 // This means the ::preview() method on this class would be invoked in
47 // case of a click event. However, since Drupal core's test runner only
48 // is able to execute PHP, not JS, there is no point in actually
49 // implementing this method, because we can never let it be called from
50 // JS; we'd have to manually call it from PHP, at which point we would
51 // not actually be testing it.
52 // Therefore we consciously choose to not implement this method, because
53 // we cannot meaningfully test it anyway.
54 'callback' => '::preview',
64 public function submitForm(array &$form, FormStateInterface $form_state) {}
69 public function validateForm(array &$form, FormStateInterface $form_state) {}