You are here

function biblio_ui_manage_biblio_validate in Bibliography Module 7.3

Validate the submitted biblio.

Make sure that year has value, unless "In press" or "Submitted" or checked.

File

modules/biblio_ui/biblio_ui.module, line 581
Main functionality file for the biblio UI module.

Code

function biblio_ui_manage_biblio_validate($form, &$form_state) {
  field_attach_form_validate('biblio', $form_state['#entity'], $form, $form_state);
  if (isset($form_state['values']['biblio_year'][LANGUAGE_NONE][0]['value']) && is_numeric($form_state['values']['biblio_year'][LANGUAGE_NONE][0]['value'])) {

    // Year has value.
    return;
  }
  if ($form_state['values']['biblio_status'][LANGUAGE_NONE][0]['value'] != 'published') {

    // "In press" or "Submitted" are checked.
    return;
  }
  form_set_error('biblio_year', t('Year is required if Publication status is "Published".'));
}