function 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\FormCode
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.