Hi,
I'm new to programming for Drupal. I'm using Drupal 7, and I want to create a custom content type programmatically. A couple of the fields are taxonomy term references. I haven't been able to find out how to set up these fields when I create my field instances. I would like to use a vocabulary I've defined called 'Artists', and I would like to use the 'Autocomplete term widget (tagging)' widget.
So far I've just got:
'performance_artist' => array(
'field_name' => 'performance_artist',
'label' => $t('Artist or Band'),
'type' => 'taxonomy_term_reference',
'widget' => array(
'type' => '', //no idea what goes here
),
Any help is greatly appreciated, thanks!
Comments
Figured it out. In case
Figured it out. In case anyone else comes across the same problem, here is how you set it up. You define the vocabulary you want to use when you create the field. In my case I set up a field like this:
and then called field_create_field.
To use the autocomplete widget, you define it when you set your field_create_instance
And with a select list instead of the autocomplete?
Any chance anyone knows how to provide a select list of current terms in the vocabulary? Surely I don't have to read all of the terms in the vocabulary and create my own list of 'allowed_values"...
You would want to
You would want to change
Fantastic! Just what I was
Fantastic! Just what I was looking for. Thanks for the code.
tag
Hi.
How would you attach the taxonomy term ("tags") into the content type?
Regards,
Jorge
In Drupal 7 you add a
In Drupal 7 you add a taxonomy term reference field
programmatically tags
I'm able to save the term into the vocabulary but not the "tag" term in the term.
Edit: I believe I read that node_save($node) couldn't achieve this in definitive guide drupal 7
In case someone is reading this I am using rules_autotag successfully to do this.