function AjaxTestMessageCommandForm::buildForm

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

Overrides FormInterface::buildForm

File

core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestMessageCommandForm.php, line 27

Class

AjaxTestMessageCommandForm
Form for testing AJAX MessageCommand.

Namespace

Drupal\ajax_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['alternate-message-container'] = [
        '#type' => 'container',
        '#id' => 'alternate-message-container',
    ];
    $form['button_default'] = [
        '#type' => 'submit',
        '#name' => 'makedefaultmessage',
        '#value' => 'Make Message In Default Location',
        '#ajax' => [
            'callback' => '::makeMessageDefault',
        ],
    ];
    $form['button_alternate'] = [
        '#type' => 'submit',
        '#name' => 'makealternatemessage',
        '#value' => 'Make Message In Alternate Location',
        '#ajax' => [
            'callback' => '::makeMessageAlternate',
        ],
    ];
    $form['button_warning'] = [
        '#type' => 'submit',
        '#name' => 'makewarningmessage',
        '#value' => 'Make Warning Message',
        '#ajax' => [
            'callback' => '::makeMessageWarning',
        ],
    ];
    return $form;
}

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