function AjaxTestDialogForm::dialog

Same name in other branches
  1. 8.9.x core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php \Drupal\ajax_test\Form\AjaxTestDialogForm::dialog()
  2. 10 core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php \Drupal\ajax_test\Form\AjaxTestDialogForm::dialog()
  3. 11.x core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php \Drupal\ajax_test\Form\AjaxTestDialogForm::dialog()

Util to render dialog in ajax callback.

Parameters

bool $is_modal: (optional) TRUE if modal, FALSE if plain dialog. Defaults to FALSE.

Return value

\Drupal\Core\Ajax\AjaxResponse An ajax response object.

2 calls to AjaxTestDialogForm::dialog()
AjaxTestDialogForm::modal in core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php
AJAX callback handler for AjaxTestDialogForm.
AjaxTestDialogForm::nonModal in core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php
AJAX callback handler for AjaxTestDialogForm.

File

core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php, line 87

Class

AjaxTestDialogForm
Dummy form for testing DialogRenderer with _form routes.

Namespace

Drupal\ajax_test\Form

Code

protected function dialog($is_modal = FALSE) {
    $content = AjaxTestController::dialogContents();
    $response = new AjaxResponse();
    $title = $this->t('AJAX Dialog & contents');
    // Attach the library necessary for using the Open(Modal)DialogCommand and
    // set the attachments for this Ajax response.
    $content['#attached']['library'][] = 'core/drupal.dialog.ajax';
    if ($is_modal) {
        $response->addCommand(new OpenModalDialogCommand($title, $content));
    }
    else {
        $selector = '#ajax-test-dialog-wrapper-1';
        $response->addCommand(new OpenDialogCommand($selector, $title, $content));
    }
    return $response;
}

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