function bat_calendar_reference_field_validate in Booking and Availability Management Tools for Drupal 7
Implements hook_field_validate().
File
- modules/
bat_calendar_reference/ bat_calendar_reference.module, line 291 - Defines a field type for referencing event information.
Code
function bat_calendar_reference_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
// Check for non-numeric values.
foreach ($items as $delta => $item) {
if (is_array($item)) {
if (!empty($item['unit_id'])) {
if (!is_numeric($item['unit_id'])) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'invalid_unit',
'message' => t('%name: invalid input.', array(
'%name' => $instance['label'],
)),
);
}
}
if (!empty($item['unit_type_id'])) {
if (!is_numeric($item['unit_type_id'])) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'invalid_unit_type',
'message' => t('%name: invalid input.', array(
'%name' => $instance['label'],
)),
);
}
}
if (!empty($item['event_type_id'])) {
if (!is_numeric($item['event_type_id'])) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'invalid_event_type',
'message' => t('%name: invalid input.', array(
'%name' => $instance['label'],
)),
);
}
}
}
}
}