function search_files_helper_add_form_validate in Search Files 7.2
Same name and namespace in other branches
- 6.2 search_files.module \search_files_helper_add_form_validate()
Validates uniqueness of name and extension.
1 string reference to 'search_files_helper_add_form_validate'
- search_files_helper_edit_form in ./
search_files.module - Form callback for adding/editing a file helper.
File
- ./
search_files.module, line 462 - Organizes and provides helper functions for extracting text from files.
Code
function search_files_helper_add_form_validate($form, $form_state) {
$id = 0;
if (isset($form_state['values']['search_file_id'])) {
$id = intval($form_state['values']['search_file_id']);
}
$name = $form_state['values']['search_files_name'];
$sql = "SELECT * FROM {search_files_helpers} WHERE name = :name AND id <> :id";
$result = db_query($sql, array(
':name' => $name,
':id' => $id,
))
->fetchAll();
foreach ($result as $row) {
form_set_error("search_files_helper", t('Helper name already in list'));
break;
}
$extension = $form_state['values']['search_files_extension'];
$sql = "SELECT * FROM {search_files_helpers} WHERE extension = :ext AND id <> :id";
$result = db_query($sql, array(
':ext' => $extension,
':id' => $id,
))
->fetchAll();
foreach ($result as $row) {
form_set_error("search_files_helper", t('Extension already in list'));
break;
}
}