1.20.x layout.admin.inc | layout_ajax_form_open_dialog($form, &$form_state) |
AJAX handler that opens a form in a dialog.
This AJAX handler is used both on the layout settings form and the layout content form.
See also
File
- modules/
layout/ layout.admin.inc, line 2704 - Admin page callbacks for the Layout module.
Code
function layout_ajax_form_open_dialog($form, &$form_state) {
// Ensure that no errors have occurred before opening the dialog.
if (form_get_errors()) {
$commands[] = ajax_command_remove('#messages');
$commands[] = ajax_command_html('#layout-messages', theme('status_messages'));
}
else {
// Get the dialog path as set in the redirect.
$dialog_path = $form_state['redirect'];
$page_callback_result = NULL;
if ($router_item = menu_get_item($dialog_path)) {
if ($router_item['access']) {
if ($router_item['include_file']) {
require_once BACKDROP_ROOT . '/' . $router_item['include_file'];
}
$page_callback_result = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
}
}
$html = is_string($page_callback_result) ? $page_callback_result : backdrop_render($page_callback_result);
if (isset($page_callback_result['#title'])) {
$title = $page_callback_result['#title'];
}
else {
$title = $router_item['title'];
}
$commands[] = ajax_command_open_modal_dialog($title, $html, array('dialogClass' => 'layout-dialog'));
}
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}