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-e
    Commented 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.
    – David
    Commented Oct 28, 2014 at 8:36

2 Answers 2

  1. Go to admin/structure/types/manage//fields
  2. 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
    – David
    Commented Oct 27, 2014 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.