I have a content type with a number field and a field for a taxonomy. I'd like that, when the user creates a node of this particular content type, the value that appears in the number field changes to a preset depending on the taxonomy term chosen.

For example, The taxonomy term is a restaurant and the number field is a price, if the user chooses an specific restaurant the price changes depending on the restaurant chosen.

  • one price per taxonomy term?
    – Codium
    Commented Mar 5, 2015 at 22:57
  • yes, although in this case most taxonomy terms would have a price of 0
    – HaPK
    Commented Mar 10, 2015 at 14:48

1 Answer 1


option 1:
use a hook_form_FORM_ID_alter MYMODULE_form_node_form_alter(&$form, $form_state) to add an ajax functionality on the taxonomy change event and populates the number field default value depending on the form_state taxonomy value.

option 2:
Add your own javascript with taxonomy terms mapped to number values and when the taxonomy term changes, change the number values to the mapped value. This is pretty much same as above without requiring ajax.

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.