In Location module input I want to disable "Postal Code" field but the node will have a mandatory vocabulary selection (vocabulary name: Postal Code).

What I want is that when I create a node with the postal code term selection it should automatically populate the "Postal Code" field of location module input from this term.

What is the right way to do it?

enter image description here


I think the only way to do this is with a custom module.

You would implement hook_form_alter to disable (or hide altogether) the location postal code on the node form.

You would then implement presave op of hook_nodeapi (drupal 6) or hook_node_presave (drupal 7) to fill in the location data.

If you don't know PHP, you could also add some custom javascript that changes the location postal code when the taxonomy drop down is changed.

| improve this answer | |
  • We can hide a location field in location settings. – AgA Dec 8 '11 at 4:27

You could use the prepopulate module. My method was to use views to create a url for node creation on my taxonomy pages. Users select the city term and on the page click on "Add a post" link and the form is prepopulated with term from the url.

| improve this answer | |

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.