public function OgVocabBehaviorHandler::presave in OG Vocabulary 7
Act on presaving an entity reference field.
Overrides EntityReference_BehaviorHandler_Abstract::presave
See also
File
- plugins/
behavior/ OgVocabBehaviorHandler.class.php, line 41
Class
- OgVocabBehaviorHandler
- OG vocab behavior handler.
Code
public function presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
foreach ($items as $delta => $item) {
if ($item['target_id'] == 'autocreate') {
$term = (object) $item;
unset($term->tid);
taxonomy_term_save($term);
$items[$delta]['target_id'] = $term->tid;
}
}
}