function elf_form_settings_validate in External Links Filter 6.3
Same name and namespace in other branches
- 7.3 elf.module \elf_form_settings_validate()
Form validation handler for elf_form_settings().
See also
File
- ./
elf.module, line 101 - Adds an icon to external and mailto links.
Code
function elf_form_settings_validate(array $form, array &$form_state) {
$values = preg_split('#\\s#', $form_state['values']['elf_domains']);
$domains = array();
$errors = array();
foreach ($values as $value) {
// Remove trailing slashes, because not all users will use those for their links.
$value = trim($value, '/');
if (strlen($value)) {
if (!menu_path_is_external($value)) {
$errors[] = $value;
}
$domains[] = $value;
}
}
if ($errors) {
form_set_error('elf_domains', format_plural(count($errors), '%domain is not a valid external domain.', '%domain are no valid external domains', array(
'%domain' => implode(', ', $errors),
)));
}
else {
form_set_value($form['elf_domains'], array_unique($domains), $form_state);
}
}