You are here

function taxonomy_tools_publisher_taxonomy_term_form_validate in Taxonomy Tools 7

Same name and namespace in other branches
  1. 8 taxonomy_tools_publisher/taxonomy_tools_publisher.module \taxonomy_tools_publisher_taxonomy_term_form_validate()

Validates the user input of Taxonomy Publisher fields.

See also

taxonomy_tools_publisher_form_taxonomy_form_term_alter()

1 string reference to 'taxonomy_tools_publisher_taxonomy_term_form_validate'
taxonomy_tools_publisher_form_taxonomy_form_term_alter in taxonomy_tools_publisher/taxonomy_tools_publisher.module
Implements hook_form_FORM_ID_alter().

File

taxonomy_tools_publisher/taxonomy_tools_publisher.module, line 95
Drupal hooks and functions to manipulate taxonomy terms.

Code

function taxonomy_tools_publisher_taxonomy_term_form_validate($form, &$form_state) {
  if (!empty($form_state['values']['field_taxonomy_term_publish_on'][LANGUAGE_NONE][0]['value'])) {
    $publish_on = $form_state['values']['field_taxonomy_term_publish_on'][LANGUAGE_NONE][0]['value'];
    if ($publish_on < REQUEST_TIME) {

      // Publish on value must be in future.
      form_set_error('field_taxonomy_term_publish_on', t('The "Publish on:" date must be in the future.'));
    }
  }
  if (!empty($form_state['values']['field_taxonomy_term_unpublish_on'][LANGUAGE_NONE][0]['value'])) {
    $unpublish_on = $form_state['values']['field_taxonomy_term_unpublish_on'][LANGUAGE_NONE][0]['value'];
    if ($unpublish_on < REQUEST_TIME) {

      // Unpublish on value must be in future.
      form_set_error('field_taxonomy_term_unpublish_on', t('The "Unpublish on:" date must be in the future.'));
    }
  }
  if (isset($publish_on) && isset($unpublish_on) && $publish_on > $unpublish_on) {

    // Unpublish on value must be after publish on value.
    form_set_error('field_taxonomy_term_unpublish_on', t('The "Unpublish on:" date must be later than the "Publish on;" date.'));
  }
}