By llvllagic_l3oy on
I'm new to Drupal 7, is there anyone knows how can i create dependent hierarchical select list for country, city, region as a field?
I'm new to Drupal 7, is there anyone knows how can i create dependent hierarchical select list for country, city, region as a field?
Comments
Any thoughts... I'm wondering
Any thoughts...
I'm wondering the same thing right now.
I have a nested taxonomy and would like to create some dependant select boxes based on the taxonomy tree... is this possible?
Hi Rmeltg, try the Hierarchical Select module
You can try the Hierarchical Select (http://drupal.org/project/hierarchical_select).
Should solve your nested taxonomy issue.
There is also an demo page for nested taxonomy selection : http://wimleers.com/demo/hierarchical-select/taxonomy
I'm very interested in this
I'm very interested in this as well. Based off what I've researched, I don't think this capability is in core and no contrib modules support this either.
Lead Developer and Founder of StreamRiot.com
Subscribe
Subscribe
I'm working on this right
I'm working on this right now.
First of all I made a taxonomy tree with the hierarchy.
Then I made a module that makes a page with a form as described in the ajax examples module from http://drupal.org/project/examples
With some brainstorming even an novice like me could set the select boxes up into 3 levels with proper ajax calls.
example form elements:
It's important to have an '#ajax' array with event and different! callback in every $form['element']
Then I used the function taxonomy_get_nested_tree as described in http://drupal.org/node/831398 (thnx to sylvaticus!) to put the taxonomy data inside my form select boxes.
example first dropdown:
Then for the following dropdowns use isset($form_state[...][...]) as seen in $value_dropdown_first in the example form module instead of $parent = 0 to declare the parent and get the right values as seen here:
Hopefully this can put you on the way and if not I'm allmost finished with my module so if anybody needs it I can set it online as an example.
Good luck,
Jurgen.
Drupal backend developer since 2011.
Open Source Webdevelopment Coding Blog
Subscribe
Hi, I am very interested too !
Interested
I would like an example of this, as I'm quite new to Drupal. If you've finished a module, a link to it would be wonderful. Otherwise, I have a few questions.
For example, I'm not sure what parts of your code are keywords or established code, and which are actually referring to your own content, nodes, or vocabulary. I'm also not certain if this is the whole picture, as you're referencing other snippets.
If you don't mind a short breakdown, that would be very helpful.
And if not, could just point out which elements refer to your own content? I've got a hierarchical vocabulary defined as well, and I'd just like to know in simple steps how to apply your solution.
Thanks!
You have to take a look at
You have to take a look at the examples module, there you can find the base of the code as shown above.
http://drupal.org/project/examples
I didn't finish the module because I found out that I could do allmost the same thing through views and the use of ajax wasn't really primary.
Good luck!
Drupal backend developer since 2011.
Open Source Webdevelopment Coding Blog
...and to make it dynamically populate from a db?
Hello there, does anyone have a code example where it shows how to populate both dropdowns with data from db tables? I'm trying everything with my code, but I'm not good enough yet and it doesnt work.
Any help will be welcome.
THE VERY LITTLE AGENCY
Hi Jurgen, have you...
...finished your form? If you could post it, it would help me a lot. And by the way: have you populated the dropdowns from a db?
Any help is welcome
Thanks
THE VERY LITTLE AGENCY
Almost but i have i slight problem
Hi
refer to this post (http://drupal.org/node/1358324) for data population from database.
If you could help me solve my problem also...
Using Ajax Chain Select Module Can solve this problem
This module is made for the same problem you have identified, i.e making dependent dropdowns for country state and city.
https://www.drupal.org/project/ajax_chain_select