You are here

function dialog_command_open_dialog in Dialog 7.2

Creates a Drupal Ajax 'open dialog' command.

Parameters

string $selector: The selector of the dialog.

string $title: The title of the dialog.

string|array $content: The content that will be placed in the dialog, either a render array or an HTML string.

array $dialog_options: (optional) Options to be passed to the dialog implementation. Any jQuery UI option can be used. See http://api.jqueryui.com/dialog.

array|null $settings: (optional) Custom settings that will be passed to the Drupal behaviors on the content of the dialog. If left empty, the settings will be populated automatically from the current request.

Return value

array An array suitable for use with the ajax_render() function.

3 calls to dialog_command_open_dialog()
ajax_deliver_dialog in ./dialog.module
Delivers the content of a page as a dialog.
dialog_command_open_modal_dialog in includes/dialog.commands.inc
Creates a Drupal Ajax 'open modal dialog' command.
dialog_test_dialog_contents in tests/dialog_test.module
Menu callback: Returns the contents for dialogs opened by dialog_test_dialog().

File

includes/dialog.commands.inc, line 61
AJAX commands.

Code

function dialog_command_open_dialog($selector, $title, $content, array $dialog_options = array(), $settings = NULL) {

  // Add the library for handling the dialog in the response.
  drupal_add_library('dialog', 'drupal.dialog.ajax');
  $dialog_options += array(
    'title' => $title,
  );
  if (is_array($content)) {
    $html = drupal_render($content);
    $content = $html;
  }

  // For consistency ensure the modal option is set to TRUE or FALSE.
  $dialog_options['modal'] = isset($dialog_options['modal']) && $dialog_options['modal'];
  return array(
    'command' => 'openDialog',
    'selector' => $selector,
    'settings' => $settings,
    'data' => $content,
    'dialogOptions' => $dialog_options,
  );
}