function word_link_add_form_validate in Word Link 8
Same name and namespace in other branches
- 7.2 word_link.admin.inc \word_link_add_form_validate()
- 7 word_link.admin.inc \word_link_add_form_validate()
Validate form for add or edit page.
File
- ./
word_link.admin.inc, line 362 - Administrative pages for the Word Link module.
Code
function word_link_add_form_validate($form, &$form_state) {
if ($form_state['values']['op'] == t('Save')) {
$args = arg();
$arg = empty($args[5]) ? 0 : $args[5];
$exist = word_link_get_link_text(trim($form_state['values']['text']), $arg);
if ($exist) {
form_set_error('text', t('This word already exists.'));
}
if (!drupal_valid_path($form_state['values']['url'])) {
form_set_error('url', t("The path '@url' is either invalid or you do not have access to it.", array(
'@url' => $form_state['values']['url'],
)));
}
if (!empty($form_state['values']['class']) && !preg_match('/^[_a-zA-Z]+[_a-zA-Z0-9-\\s]*$/', trim($form_state['values']['class']))) {
form_set_error('class', t('Class is not valid.'));
}
}
}