function AjaxTestForm::helloWorld

Same name and namespace in other branches
  1. 10 core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php \Drupal\ajax_test\Form\AjaxTestForm::helloWorld()

An AJAX callback that prints "Hello World!" as a message.

Parameters

array $form: The form array to remove elements from.

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

Return value

\Drupal\Core\Ajax\AjaxResponse An AJAX response.

File

core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php, line 76

Class

AjaxTestForm
Dummy form for testing DialogRenderer with _form routes.

Namespace

Drupal\ajax_test\Form

Code

public function helloWorld(array &$form, FormStateInterface $form_state) {
    $response = new AjaxResponse();
    $response->addCommand(new MessageCommand('Hello world!'));
    return $response;
}

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