1 layout.admin.inc | layout_block_configure_ajax_update($form, $form_state) |
AJAX callback to update the underlying layout form after updating a block.
File
- core/
modules/ layout/ layout.admin.inc, line 1876 - Admin page callbacks for the Layout module.
Code
function layout_block_configure_ajax_update($form, $form_state) {
/* @var Layout $layout */
$layout = $form_state['layout'];
/* @var Block $block */
$block = $form_state['block'];
/* @var LayoutRendererStandard $renderer */
$renderer = $form_state['renderer'];
$added_to_region = $block->is_new ? (isset($layout->in_progress['region_name']) ? $layout->in_progress['region_name'] : $form_state['values']['region']) : FALSE;
// Display error messages in the form if any.
if (form_get_errors()) {
$html = '';
$html .= theme('status_messages');
$html .= backdrop_render($form);
$title = isset($form['#title']) ? $form['#title'] : backdrop_get_title();
$commands[] = ajax_command_open_modal_dialog($title, $html, array('dialogClass' => 'layout-dialog'));
}
// If a new block, add to the bottom of the region.
elseif ($added_to_region) {
$commands[] = ajax_command_close_modal_dialog();
$commands[] = ajax_command_remove('#layout-editor-block-' . $block->uuid);
$commands[] = ajax_command_append('#layout-editor-region-' . $added_to_region . ' .layout-editor-region-content', $renderer->renderBlock($block));
}
// If editing a block, replace the block with its placeholder.
else {
$commands[] = ajax_command_close_modal_dialog();
$commands[] = ajax_command_replace('#layout-editor-block-' . $block->uuid, $renderer->renderBlock($block));
}
// Remove the page title pseudo region if we're adding a Title block or a
// Combo block.
if ($block->module == 'system' && $block->delta == 'page_components' && ($block->childDelta == 'title' || $block->childDelta == 'title_combo')) {
$commands[] = ajax_command_replace('#layout-editor-title', '<div id="layout-title-region-empty"></div>');
}
// Update the messages area.
if ($message = layout_locked_message($layout, 'layout')) {
backdrop_set_message($message, 'warning');
}
$commands[] = ajax_command_remove('#messages');
$commands[] = ajax_command_html('#layout-messages', theme('status_messages'));
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}