function biblio_form_validate in Bibliography Module 6.2
Same name and namespace in other branches
- 6 biblio.module \biblio_form_validate()
- 7.2 biblio.module \biblio_form_validate()
Implementation of hook_validate().
Errors should be signaled with form_set_error().
1 string reference to 'biblio_form_validate'
- biblio_form in ./
biblio.module - Implements hook_form().
File
- ./
biblio.module, line 1754 - Main file for Drupal module biblio.
Code
function biblio_form_validate($form, &$form_state) {
$op = isset($form['#post']['op']) ? $form['#post']['op'] : ($form['#post']['biblio_type'] > 0 ? t('Save') : '');
switch ($op) {
case t('Save'):
if ($form_state['storage']['biblio_type'] == $form_state['values']['biblio_type'] || !empty($form['#node']->biblio_type) && $form['#node']->biblio_type == $form_state['values']['biblio_type']) {
unset($form_state['storage']);
}
else {
// Clear validation errors that other modules might have set.
// This assumes that Biblio has a greater weight than those
// other modules.
form_set_error(NULL, '', TRUE);
drupal_get_messages('error');
$form_state['storage']['biblio_type'] = $form_state['values']['biblio_type'];
$form_state['submitted'] = TRUE;
$form_state['rebuild'] = TRUE;
return;
}
}
if (!empty($node_data)) {
$form_state['values'] = array_merge($form_state['values'], $node_data[0]);
$form_state['storage']['biblio_type'] = $node_data[0]['biblio_type'];
return;
}
if (isset($form_state['values']['biblio_keywords'])) {
module_load_include('inc', 'biblio', 'includes/biblio.keywords');
if (!is_array($form_state['values']['biblio_keywords'])) {
$form_state['values']['biblio_keywords'] = biblio_explode_keywords($form_state['values']['biblio_keywords']);
}
foreach ($form_state['values']['biblio_keywords'] as $keyword) {
if (strlen($keyword) > 255) {
form_set_error('biblio_keywords', t('No single keyword can be greater than 255 characters in length, the word: @kw exceeds this length', array(
'@kw' => $keyword,
)));
}
}
}
}