function biblio_node_form_validate in Bibliography Module 7
Same name and namespace in other branches
- 7.2 biblio.module \biblio_node_form_validate()
Implements hook_validate().
Errors should be signaled with form_set_error().
1 string reference to 'biblio_node_form_validate'
- biblio_form in ./
biblio.module - Implements hook_form().
File
- ./
biblio.module, line 1643 - Bibliography Module for Drupal.
Code
function biblio_node_form_validate($form, &$form_state) {
if ($form_state['triggering_element']['#value'] == t('Next') || $form_state['triggering_element']['#value'] == t('Change Publication Type')) {
$form_state['rebuild'] = TRUE;
$form_state['biblio_type'] = $form_state['values']['biblio_type'];
if ($form_state['values']['biblio_type'] == 0) {
form_set_error('biblio_type', t('Please select a publication type.'));
}
return;
}
$format = new stdClass();
foreach (_biblio_get_formatted_fields() as $field) {
if (isset($form_state['values'][$field]['format'])) {
$format->format = $form_state['values'][$field]['format'];
if (!filter_access($format)) {
form_set_error($field, t('You do not have access to the !format format', array(
'!format' => $format->format,
)));
}
}
}
if (isset($form_state['values']['biblio_keywords'])) {
require_once drupal_get_path('module', 'biblio') . '/includes/biblio.keywords.inc';
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,
)));
}
}
}
if (isset($form_state['biblio_fields'])) {
$vtabs = biblio_node_form_vtab_info();
foreach ($vtabs as $tab) {
$tabs[$tab['tab_id']] = $tab['title'];
}
foreach ($form_state['biblio_fields'] as $key => $fld) {
if ($fld['required'] && isset($form_state['values'][$key]) && empty($form_state['values'][$key])) {
$tab = $tabs[$fld['vtab']];
form_set_error($key, t('@fld field is required (on the %tab tab).', array(
'@fld' => $fld['title'],
'%tab' => $tab,
)));
}
}
}
}