On this page
function taxonomy_field_presave
taxonomy_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)
Implements hook_field_presave().
Create any new terms defined in a freetagging vocabulary.
Related topics
File
- modules/taxonomy/taxonomy.module, line 1898
- Enables the organization of content into categories.
Code
function taxonomy_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
foreach ($items as $delta => $item) {
if ($item['tid'] == 'autocreate') {
$term = (object) $item;
unset($term->tid);
taxonomy_term_save($term);
$items[$delta]['tid'] = $term->tid;
}
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.module/function/taxonomy_field_presave/7.x