function timefield_field_validate in Timefield 7
Implements hook_field_validate().
File
- ./
timefield.module, line 616 - Defines a Field API field for time
Code
function timefield_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
foreach ($items as $delta => $item) {
if (!timefield_field_is_empty($item, array())) {
if (!is_numeric($item['value'])) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'timefield_invalid_value',
'message' => t('Time values are incorrect.'),
);
}
// If field instance requires an end time, check to see that is set
if ($field['settings']['totime'] == 'required') {
if (!isset($item['value2']) || timefield_is_empty_value($item['value2'])) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'timefield_invalid_value2',
'message' => t('An End Time Is required.'),
);
}
}
}
if (isset($item['value2']) && !timefield_is_empty_value($item['value2'])) {
if (!is_numeric($item['value2'])) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'timefield_invalid_value2',
'message' => t('Time values are incorrect.'),
);
}
}
}
}