1 layout.admin.inc | layout_content_form_validate($form, &$form_state) |
Validate the layout settings form.
File
- core/
modules/ layout/ layout.admin.inc, line 1265 - Admin page callbacks for the Layout module.
Code
function layout_content_form_validate($form, &$form_state) {
/* @var Layout $layout */
$layout = $form_state['layout'];
// Ensure that the main page content block is only positioned once and that
// default layouts include the main page content.
$main_blocks_found = 0;
foreach ($layout->content as $block) {
if ($block->module === 'system' && $block->delta === 'main') {
$main_blocks_found++;
}
}
if ($main_blocks_found > 1) {
form_error($form['content']['positions'], t('The "@block" block may only be added once to this layout.', array('@block' => t('Main page content'))));
}
elseif ($main_blocks_found === 0 && ($layout->name === 'default' || $layout->name === 'admin_default')) {
form_error($form['content']['positions'], t('The "@block" block must be added to this layout.', array('@block' => t('Main page content'))));
}
// Ensure that no block is positioned more than once. This is merely a sanity
// check, it should not occur within the normal interface.
$all_uuids = array();
foreach ($layout->positions as $uuids) {
foreach ($uuids as $uuid) {
if (in_array($uuid, $all_uuids)) {
form_error($form['content']['positions'], t('The "@block" block has incorrectly been positioned multiple times. This may indicate an incorrectly saved layout configuration.', array('@block' => $layout->content[$uuid]->getAdminTitle())));
}
$all_uuids[] = $uuid;
}
}
// Let the layout do any specific validations.
$layout->formValidate($form, $form_state);
}