Menu callback: Renders a form elements and links with #ajax['dialog'].
function ajax_test_dialog() {
// Add two wrapper elements for testing non-modal dialogs. Modal dialogs use
// the global drupal-modal wrapper by default.
$build['dialog_wrappers'] = array(
'#markup' => '<div id="ajax-test-dialog-wrapper-1"></div><div id="ajax-test-dialog-wrapper-2"></div>',
);
// Dialog behavior applied to a button.
$build['form'] = drupal_get_form('ajax_test_dialog_form');
// Dialog behavior applied to a #type => 'link'.
$build['link'] = array(
'#type' => 'link',
'#title' => 'Link 1 (modal)',
'#href' => 'ajax-test/dialog-contents',
'#ajax' => array(
'dialog' => array(
'modal' => TRUE,
),
),
);
// Dialog behavior applied to links rendered by theme_links().
$build['links'] = array(
'#theme' => 'links',
'#links' => array(
'link2' => array(
'title' => 'Link 2 (modal)',
'href' => 'ajax-test/dialog-contents',
'ajax' => array(
'dialog' => array(
'modal' => TRUE,
),
),
),
'link3' => array(
'title' => 'Link 3 (non-modal)',
'href' => 'ajax-test/dialog-contents',
'ajax' => array(
'dialog' => array(),
'wrapper' => 'ajax-test-dialog-wrapper-2',
),
),
),
);
return $build;
}