public function sio__annotation::validate
3.x sio__annotation.inc | public sio__annotation::validate($entity_type, $entity, $langcode, $items, &$errors) |
Overrides TripalField::validate
See also
File
- tripal_chado/
includes/ TripalFields/ sio__annotation/ sio__annotation.inc, line 56
Class
Code
public function validate($entity_type, $entity, $langcode, $items, &$errors) {
// If we don't have an entity then we don't want to validate. The case
// where this could happen is when a user is editing the field settings
// and trying to set a default value. In that case there's no entity and
// we don't want to validate. There will always be an entity for creation
// and update operations of a content type.
if (!$entity) {
return;
}
$field_name = $this->field['field_name'];
foreach ($items as $delta => $item) {
// Get the term that matches.
$cvterm_name = $item['cvterm_name'];
$cv_id = $item['cv_id'];
if ($cvterm_name and $cv_id) {
$cvterm = chado_generate_var('cvterm', array(
'cv_id' => $cv_id,
'name' => $cvterm_name,
));
if (!$cvterm) {
$errors[$field_name][$langcode][$delta][] = array(
'message' => t("Cannot find a term that matches the term name and vocabulary."),
'error' => 'cvterm_name'
);
}
}
}
}