You are here

function tzfield_field in Time Zone Field 6

Implementation of hook_field().

File

./tzfield.module, line 126
Defines a field type for storing timezones.

Code

function tzfield_field($op, &$node, $field, &$items, $teaser, $page) {
  switch ($op) {
    case 'validate':
      module_load_include('inc', 'content', 'content_node_form');
      $timezones = tzfield_timezones($field);
      foreach ($items as $delta => $item) {
        if (is_array($item) && !empty($item['timezone']) && !in_array($item['timezone'], $timezones)) {
          form_set_error($field['field_name'] . '][' . $delta . '][timezone][timezone', t('%name: This timezone is not valid.', array(
            '%name' => t($field['widget']['label']),
          )));
        }
      }
      return $items;
  }
}