You are here

function office_hours_field_validate in Office Hours 7

Implements hook_field_validate(). Is called a.o. when saving the content type field (default value) and content.

File

includes/office_hours.field.inc, line 292
Implements the office_hours Field.

Code

function office_hours_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
  if (!empty($entity_type) && $instance['required']) {
    if (empty($items) || office_hours_instance_is_empty($items)) {
      $errors[$field['field_name']][$langcode][0][] = array(
        'error' => 'office_hours_required',
        'message' => t('%name field is required. Please fill in one or more of the hour blocks.', array(
          '%name' => $instance['label'],
        )),
      );
    }
  }
}