diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php index 3f4d510..4aeb711 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php @@ -63,8 +63,8 @@ public function massageFormValues(array $values, array $form, array &$form_state // Collect candidate vocabularies. foreach ($field['settings']['allowed_values'] as $tree) { - if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) { - $vocabularies[$vocabulary->vid] = $vocabulary; + if ($vocabulary = taxonomy_vocabulary_load($tree['vocabulary'])) { + $vocabularies[$vocabulary->id()] = $vocabulary; } } @@ -79,9 +79,8 @@ public function massageFormValues(array $values, array $form, array &$form_state $vocabulary = reset($vocabularies); $term = array( 'tid' => 'autocreate', - 'vid' => $vocabulary->vid, + 'vid' => $vocabulary->id(), 'name' => $value, - 'vocabulary_machine_name' => $vocabulary->machine_name, ); } $terms[] = (array)$term; diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index aa5eca1..dd241de 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -1408,33 +1408,7 @@ function taxonomy_autocomplete_validate($element, &$form_state) { // @see Drupal\taxonomy\Plugin\field\widget\TaxonomyAutocompleteWidget:massageFormValues() $typed_terms = array(); if ($tags = $element['#value']) { - // Collect candidate vocabularies. - $field = field_widget_field($element, $form_state); - $vocabularies = array(); - foreach ($field['settings']['allowed_values'] as $tree) { - if ($vocabulary = taxonomy_vocabulary_load($tree['vocabulary'])) { - $vocabularies[$vocabulary->id()] = $vocabulary; - } - } - - // Translate term names into actual terms. $typed_terms = drupal_explode_tags($tags); - foreach ($typed_terms as $typed_term) { - // See if the term exists in the chosen vocabulary and return the tid; - // otherwise, create a new 'autocreate' term for insert/update. - if ($possibilities = entity_load_multiple_by_properties('taxonomy_term', array('name' => trim($typed_term), 'vid' => array_keys($vocabularies)))) { - $term = array_pop($possibilities); - } - else { - $vocabulary = reset($vocabularies); - $term = array( - 'tid' => 'autocreate', - 'vid' => $vocabulary->id(), - 'name' => $typed_term, - ); - } - $value[] = (array)$term; - } } form_set_value($element, $typed_terms, $form_state); }