You are here

function entity_embed_command_open_modal_dialog in Entity Embed 7

Creates a Drupal Ajax 'open modal dialog' command.

The modal dialog differs from the normal modal provided by entity_embed_command_open_dialog in that a modal prevents other interactions on the page until the modal has been completed. Drupal provides a built-in modal for this purpose, so no selector needs to be provided.

Parameters

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) Settings 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

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

1 call to entity_embed_command_open_modal_dialog()
entity_embed_dialog in ./entity_embed.admin.inc
Menu callback; Provide the dialog for embedding entities.

File

includes/entity_embed.commands.inc, line 126
AJAX commands.

Code

function entity_embed_command_open_modal_dialog($title, $content, array $dialog_options = array(), $settings = NULL) {
  $dialog_options['modal'] = TRUE;
  $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' => '#drupal-modal',
    'settings' => $settings,
    'data' => $content,
    'dialogOptions' => $dialog_options,
  );
}