diff --git a/entity.module b/entity.module index 6cdc817..856a8e0 100644 --- a/entity.module +++ b/entity.module @@ -1245,7 +1245,7 @@ function _entity_info_add_metadata(&$entity_info) { $entity_info['taxonomy_term']['description'] = t('Taxonomy terms are used for classifying content.'); $entity_info['taxonomy_term']['access callback'] = 'entity_metadata_taxonomy_access'; $entity_info['taxonomy_term']['creation callback'] = 'entity_metadata_create_object'; - $entity_info['taxonomy_term']['save callback'] = 'taxonomy_term_save'; + $entity_info['taxonomy_term']['save callback'] = 'entity_metadata_taxonomy_term_save'; $entity_info['taxonomy_term']['deletion callback'] = 'taxonomy_term_delete'; $entity_info['taxonomy_term']['view callback'] = 'entity_metadata_view_single'; $entity_info['taxonomy_term']['form callback'] = 'entity_metadata_form_taxonomy_term'; diff --git a/modules/callbacks.inc b/modules/callbacks.inc index 62d5f31..962fd6e 100644 --- a/modules/callbacks.inc +++ b/modules/callbacks.inc @@ -799,6 +799,18 @@ function entity_metadata_form_taxonomy_term($term) { } /** + * Callback to save a taxonomy term. + */ +function entity_metadata_taxonomy_term_save($term) { + if (isset($term->vocabulary_machine_name) && !isset($term->vid)) { + if ($vocabulary = taxonomy_vocabulary_machine_name_load($term->vocabulary_machine_name)) { + $term->vid = $vocabulary->vid; + } + } + return taxonomy_term_save($term); +} + +/** * Callback to get the form of a vocabulary. */ function entity_metadata_form_taxonomy_vocabulary($term) {