I'd like to add a new taxonomy term and assign the node while adding or editing the node. I don't want to use any of third party modules. I'd like to do it by myself in code. Maybe some of you have faced this problem. Anyone know how to do it?
-
This is how I understood this. You want to programmatically add a new taxonomy term to a node you are adding/editing. You wrote that you want to do it 'in code'. Do you mean that you don't want add it through web UI? Do you already have a taxonomy field in your node type?– jiv-eCommented Oct 27, 2014 at 20:06
-
No, what I meant is to add terms (on the fly) while being on node add/edit form (without going to structure > taxonomy etc.). This should be done in UI, but like I said I don't want to use third party modules like Hierarchical Select, I just want to make it by my own in custom module (code). Hope that makes it clear now.– DavidCommented Oct 28, 2014 at 8:36
Add a comment
|
2 Answers
- Go to admin/structure/types/manage//fields
Add new field:
- Select field type -> Term reference
- Select a widget -> Autocomplete term widget (tagging)
You should now be able to add new terms in node add/edit form via the autocomplete field. You don't need any custom modules. Drupal's core taxonomy module offers this functionality.
you can use the core term reference field and make the field formatter to use tags style
-
this can't be tag style, it must be standard term, because of hierarchy which exists already and it's in use– DavidCommented Oct 27, 2014 at 16:18