taxonomy_field_validate

Versions
7
taxonomy_field_validate($obj_type, $object, $field, $instance, $langcode, $items, &$errors)

Implements hook_field_validate().

Possible error codes:

  • 'taxonomy_term_illegal_value': The value is not part of the list of allowed values.

Code

modules/taxonomy/taxonomy.module, line 1041

<?php
function taxonomy_field_validate($obj_type, $object, $field, $instance, $langcode, $items, &$errors) {
  $allowed_values = taxonomy_allowed_values($field);
  $widget = field_info_widget_types($instance['widget']['type']);

  foreach ($items as $delta => $item) {
    if (!empty($item['tid'])) {
      if (!isset($allowed_values[$item['tid']])) {
        $errors[$field['field_name']][$langcode][$delta][] = array(
          'error' => 'taxonomy_term_illegal_value',
          'message' => t('%name: illegal value.', array('%name' => t($instance['label']))),
        );
      }
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.