You are here

function office_hours_field in Office Hours 6

Same name and namespace in other branches
  1. 5 office_hours.module \office_hours_field()
  2. 6.2 office_hours.module \office_hours_field()

Implementation of hook_field().

File

./office_hours.module, line 209
Creates a field and widget for inserting working or office hours per day

Code

function office_hours_field($op, &$node, $field, &$items, $teaser, $page) {
  switch ($op) {
    case 'validate':
      foreach ($items as $delta => $item) {
        if ($field['valhrs']) {
          if (!empty($item['starthours']) && !empty($item['endhours'])) {
            $error_field = $field['field_name'] . '][' . $delta . '][endhours';
            if ($item['starthours'] > $item['endhours']) {
              form_set_error($error_field, t('Closing hours are earlier than opening hours validator'));
            }
          }
        }
      }
      break;
    case 'presave':
      break;
    case 'insert':
    case 'update':
      $items = _office_hours_set_weight($items);
      break;
  }
}