Implement Country and Province dropdown list in drupal 7 programmatically using Location module

1.1k Views Asked by At

I am implementing a Drupal 7 signup form (through a custom module) where users should be able to indicate their location (Country + Province/State) using dropdown lists. From the description of Location module, this seems possible (by using APIs or someother way). I am new to Drupal and have no idea of how to implement this in the custom module programatically (using location module's APIs). I've googled about this for a couple of days, but couldn't make much progress.

Any sample code or leads would be greatly appreciated.

Thanks a Ton.

2

There are 2 best solutions below

0
On BEST ANSWER

Ok I finally figured out how this is done. We just need to call the api function like here $country = array(location_get_provinces("us"));
This returns the provinces of the country which is supplied as a parameter.

2
On

If location module provides what you what, you should use it. Otherwise try with address field module.