function AjaxTestDialogForm::buildForm

Same name in other branches
  1. 8.9.x core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php \Drupal\ajax_test\Form\AjaxTestDialogForm::buildForm()
  2. 10 core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php \Drupal\ajax_test\Form\AjaxTestDialogForm::buildForm()
  3. 11.x core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php \Drupal\ajax_test\Form\AjaxTestDialogForm::buildForm()

Overrides FormInterface::buildForm

File

core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php, line 29

Class

AjaxTestDialogForm
Dummy form for testing DialogRenderer with _form routes.

Namespace

Drupal\ajax_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['button1'] = [
        '#type' => 'submit',
        '#name' => 'button1',
        '#value' => 'Button 1 (modal)',
        '#ajax' => [
            'callback' => '::modal',
        ],
    ];
    $form['button2'] = [
        '#type' => 'submit',
        '#name' => 'button2',
        '#value' => 'Button 2 (non-modal)',
        '#ajax' => [
            'callback' => '::nonModal',
        ],
    ];
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.