function simplemeta_meta_form_validate_save in Simple Meta 7
Same name and namespace in other branches
- 6.2 simplemeta.module \simplemeta_meta_form_validate_save()
SimpleMeta form validation callback on save.
1 string reference to 'simplemeta_meta_form_validate_save'
- simplemeta_meta_form in ./
simplemeta.module - SimpleMeta form builder.
File
- ./
simplemeta.module, line 474 - SimpleMeta module.
Code
function simplemeta_meta_form_validate_save($form, &$form_state) {
$values = $form_state['values'];
$meta = $values['_meta'];
$path = $values['_path'];
$lang = $values['_language'];
$normal_path = drupal_get_normal_path($path);
if ($path != $normal_path) {
$path = $normal_path;
}
if (!url_is_external($path)) {
$parsed_link = parse_url($path);
if ($path != $parsed_link['path']) {
$path = $parsed_link['path'];
}
// @todo do we need to check the access?
// @see menu_edit_item_validate()
if (!trim($path)) {
form_set_error('_path', t('Path is invalid'));
}
$form_state['values']['_path'] = $path;
}
else {
form_set_error('_path', t('Path can be only internal'));
}
if (isset($meta->sid) && !simplemeta_meta_load($meta->sid)) {
form_set_error('_meta', t("Meta #%sid doesn't exist anymore", array(
'%id' => $meta->sid,
)));
}
elseif (!isset($meta->sid) && simplemeta_meta_load_by_path($path, $lang)) {
form_set_error('_meta', t("Meta for this page in this language already exists"));
}
$info = simplemeta_get_info();
foreach ($info as $key => $definition) {
if (isset($definition['validate']) && function_exists($definition['validate'])) {
$function = $definition['validate'];
$function($form, $form_state);
}
}
}