You are here

function hook_node_recur_validate_dates in Node recur 7

Implements hook_node_recur_validate_dates().

This hook is invoked when validating the node recur date form. It will only be called if there are no recorded validation errors found by this module.

Parameters

$node: The node being recurred.

$form_state: The form's form state array.

Return value

An array of errors to be printed to the screen. Each error is an array with the keys 'field' (the name of the field) and 'error' (the message to print to the screen).

1 invocation of hook_node_recur_validate_dates()
node_recur_node_recur_form_validate in ./node_recur.pages.inc
Validate the node recur form

File

./node_recur.api.php, line 50

Code

function hook_node_recur_validate_dates($node, $form_state) {
  $errors = array();
  if ($node->type == 'class') {
    if ($form_state['values']['option'] == 'days') {
      if (isset($form_state['values']['days']['monday'])) {
        $errors[] = array(
          'field' => 'days',
          'message' => t('Classes cannot occur on Monday.'),
        );
      }
      if (isset($form_state['values']['days']['tuesday'])) {
        $errors[] = array(
          'field' => 'days',
          'message' => t('Classes cannot occur on Tuesday.'),
        );
      }
    }
  }
  return $errors;
}