You are here

public function AjaxTestMessageCommandForm::buildForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestMessageCommandForm.php \Drupal\ajax_test\Form\AjaxTestMessageCommandForm::buildForm()
  2. 9 core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestMessageCommandForm.php \Drupal\ajax_test\Form\AjaxTestMessageCommandForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

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;
}