function AjaxTestController::dialogContents

Same name in other branches
  1. 9 core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php \Drupal\ajax_test\Controller\AjaxTestController::dialogContents()
  2. 8.9.x core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php \Drupal\ajax_test\Controller\AjaxTestController::dialogContents()
  3. 11.x core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php \Drupal\ajax_test\Controller\AjaxTestController::dialogContents()

Example content for dialog testing.

Return value

array Renderable array of AJAX dialog contents.

3 calls to AjaxTestController::dialogContents()
AjaxTestDialogForm::dialog in core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php
Util to render dialog in ajax callback.
DialogTest::testDialog in core/tests/Drupal/FunctionalJavascriptTests/Ajax/DialogTest.php
Tests sending non-JS and AJAX requests to open and manipulate modals.
OffCanvasDialogTest::testDialog in core/modules/system/tests/src/Functional/Ajax/OffCanvasDialogTest.php
Tests sending AJAX requests to open and manipulate off-canvas dialog.
1 string reference to 'AjaxTestController::dialogContents'
ajax_test.routing.yml in core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml
core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml

File

core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php, line 24

Class

AjaxTestController
Provides content for dialog tests.

Namespace

Drupal\ajax_test\Controller

Code

public static function dialogContents() {
    // This is a regular render array; the keys do not have special meaning.
    $content = [
        '#title' => '<em>AJAX Dialog & contents</em>',
        'content' => [
            '#markup' => 'Example message',
        ],
        'cancel' => [
            '#type' => 'link',
            '#title' => 'Cancel',
            '#url' => Url::fromRoute('<front>'),
            '#attributes' => [
                // This is a special class to which JavaScript assigns dialog closing
                // behavior.
'class' => [
                    'dialog-cancel',
                ],
            ],
        ],
    ];
    return $content;
}

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