function AjaxTestDialogForm::dialog
Same name in other branches
- 9 core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php \Drupal\ajax_test\Form\AjaxTestDialogForm::dialog()
- 8.9.x core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php \Drupal\ajax_test\Form\AjaxTestDialogForm::dialog()
- 10 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.
bool $is_url: (optional) True if modal is from a URL, Defaults to FALSE.
Return value
\Drupal\Core\Ajax\AjaxResponse An ajax response object.
3 calls to AjaxTestDialogForm::dialog()
- AjaxTestDialogForm::modal in core/
modules/ system/ tests/ modules/ ajax_test/ src/ Form/ AjaxTestDialogForm.php - AJAX callback handler for AjaxTestDialogForm.
- AjaxTestDialogForm::modalFromUrl in core/
modules/ system/ tests/ modules/ ajax_test/ src/ Form/ AjaxTestDialogForm.php - AJAX callback handler for Url modal, 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 108
Class
- AjaxTestDialogForm
- Dummy form for testing DialogRenderer with _form routes.
Namespace
Drupal\ajax_test\FormCode
protected function dialog(bool $is_modal = FALSE, bool $is_url = 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) {
if ($is_url) {
$response->addCommand(new OpenModalDialogWithUrl(Url::fromRoute('ajax_test.dialog_form')->toString(), []));
}
else {
$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.