0

What I'm trying to say at the title is, I have this Select List field that gets its values from a taxonomy called "Thing".

The taxonomy term are (Thing-1,Thing-2,Other). When "Other" is selected a text field called "Specify" will appear. What I'm trying to do is when the user submits the form. Whatever he placed on the "Specify" field will be added as a "Thing" Taxonomy term.

So the terms will be (Thing-1,Thing-2,New Thing,Other).

I might be over explaining this, but I can't find anything on google.

  • You might need to add a custom submit handler for the form via form_alter hook, and in that submit (seeing as you are not using Autocomplete term widget (tagging)) you will check if taxonomy term selected is 'Other', then check if the value in 'Specify' is already a taxonomy terms via taxonomy_get_term_by_name(), and then depending on that create a new taxonomy term for the vocabulary and save it via taxonomy_term_save(). – J. Reynolds Sep 8 '14 at 8:15
  • I'm very new to drupal and a little more details would be very appreciated, probably some code snippets perhaps? I completely understood your instructions but I'm not sure where to start? – Richard Sep 8 '14 at 9:16
  • drupal.stackexchange.com/questions/137100/… Please let me know if my answer to the linked question would help you. Thank you. – Ataboy Josef Nov 18 '14 at 12:55
1

If you are using Select (or Other) module and it does not specifically need to be a taxonomy term, there is an option for exactly this:

On the field edit page, the "Other value as default value" allows you to select how other will be handled:

  • Add the values to the other textfield-> store the value but don't change the list

  • Append the values to the current list-> store the value and add to the list attached to the node/user/entity

  • Append the values to the available options-> store the value and add the value to the list so that it can be selected on other nodes/users/entities

  • Ignore the values-> do not store the value

EDIT (courtesy of DuaelFr)

You will need the 7.x-3.x-dev version to be able to use this module on a Taxonomy Reference Widget.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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