function AjaxTestMessageCommandForm::buildForm

Same name in other branches
  1. 9 core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestMessageCommandForm.php \Drupal\ajax_test\Form\AjaxTestMessageCommandForm::buildForm()
  2. 8.9.x 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' => 'make_default_message',
        '#value' => 'Make Message In Default Location',
        '#ajax' => [
            'callback' => '::makeMessageDefault',
        ],
    ];
    $form['button_alternate'] = [
        '#type' => 'submit',
        '#name' => 'make_alternate_message',
        '#value' => 'Make Message In Alternate Location',
        '#ajax' => [
            'callback' => '::makeMessageAlternate',
        ],
    ];
    $form['button_warning'] = [
        '#type' => 'submit',
        '#name' => 'make_warning_message',
        '#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.