Validates the submitted site-information form.
function system_site_information_settings_validate($form, &$form_state) {
// Check for empty front page path.
if (empty($form_state['values']['site_frontpage'])) {
// Set to default "user".
form_set_value($form['front_page']['site_frontpage'], 'user', $form_state);
}
else {
// Get the normal path of the front page.
form_set_value($form['front_page']['site_frontpage'], drupal_container()
->get('path.alias_manager')
->getSystemPath($form_state['values']['site_frontpage']), $form_state);
}
// Validate front page path.
if (!drupal_valid_path($form_state['values']['site_frontpage'])) {
form_set_error('site_frontpage', t("The path '%path' is either invalid or you do not have access to it.", array(
'%path' => $form_state['values']['site_frontpage'],
)));
}
// Get the normal paths of both error pages.
if (!empty($form_state['values']['site_403'])) {
form_set_value($form['error_page']['site_403'], drupal_container()
->get('path.alias_manager')
->getSystemPath($form_state['values']['site_403']), $form_state);
}
if (!empty($form_state['values']['site_404'])) {
form_set_value($form['error_page']['site_404'], drupal_container()
->get('path.alias_manager')
->getSystemPath($form_state['values']['site_404']), $form_state);
}
// Validate 403 error path.
if (!empty($form_state['values']['site_403']) && !drupal_valid_path($form_state['values']['site_403'])) {
form_set_error('site_403', t("The path '%path' is either invalid or you do not have access to it.", array(
'%path' => $form_state['values']['site_403'],
)));
}
// Validate 404 error path.
if (!empty($form_state['values']['site_404']) && !drupal_valid_path($form_state['values']['site_404'])) {
form_set_error('site_404', t("The path '%path' is either invalid or you do not have access to it.", array(
'%path' => $form_state['values']['site_404'],
)));
}
}