I would like to create dynamic select lists. For instance, my page may have two select lists on it, lets use an analogy from the auto industry.
First select box:
Chevrolet
Dodge
Ford
Toyota
Select select box would be populated based on first;
Chevrolet -> Cobalt
Chevrolet -> Silverado 1500
Dodge -> Ram 1500
Dodge -> Ram 2500
Dodge -> Avenger
Ford -> Mustang
Ford -> F150
Ford -> F250
Toyota -> Celica
Toyota -> Avalon
Toyota -> Camry
Toyota -> Tundra
If someone chooses Toyota in the first box, they would be given a list of the vehicles in the second box. So, it would be Make -> Model. I think this would need to go further than just 2 dynamic boxes though. Someone may want Year -> Make -> Model -> Trim Level. I would love to see this type of feature, or if there is currently a way to accomplish this, please let me know.
I actually have a project that requires this type of functionality, but it is more for choose schools (high school or college). One set would be for high school and the other set for college. It would be State -> City -> School.
Thanks,
Shane
Comments
Comment #1
quicksketchWhat you've described here is a very difficult problem and it is not yet supported in Webform. Moving to the 3.x branch where any new features would be added. This feature will never be in the Drupal 5 version of Webform.
Comment #2
quicksketchComment #3
Victor Safronov commentedThis feature could be very useful.
And the hierarchical_select module has comprehensive API, so I suppose it's not a big trouble.
Comment #4
quicksketchThe biggest problem with this request is figuring out how to support hierarchies in a way that's easily configurable. Right now Webform has support for a single level of hierarchy through Optgroups. Providing more than one level could require us to re-architect a few things. If we did support hierarchies, we'd definitely end up using Hierarchical Select module for the display of such options.
Comment #5
Alexander Matveev commentedSubscribing.
Comment #6
404 commentedsubscribing
Comment #7
drupov commentedSubscribe
Comment #8
webankit commentedsub
Comment #9
henneman commentedSubscribe
Comment #10
flamingvan commentedQuicksketch, regarding your post #4, I have been thinking about this a lot. I have a client who's interested in this feature and I've been working on writing up an estimate (not an easy one).
Regarding the interface, wouldn't Drupal's existing drag and drop feature be a nice way to do it? So for example you drag one select box under another (and over a bit) and that indicates the hierarchy? Forgive me if this is an obvious solution.
My potential client needs, in some cases, hierarchies in which a parent select has multiple children, meaning that a selection of one box changes multiple other selection boxes.
I've been considering a couple different ways of handling this project, including writing a new webform component from scratch, or just using optgroups in the existing select component and then using Jquery to create the dependencies.
Any opionion on what the best way to go about it is?
Thanks
Comment #11
flamingvan commentedI am getting pretty close to a solution and it is very different from what I wrote above. I'm planning to use the hierarchical select API and write a custom component. Here's an idea for how a user would enter data for the tiered lists, in which the columns represent parent, label, value:
root | food | food
root| beverage | beverage
food | hot | hot
food |cold |cold
hot | pasta | pasta
cold | sandwich |sandwich
beverage | soda | soda
beverage | juice | juice
juice | orange |orange
etc.
I think that should work well enough, right?
quicksketch, I love your webform module from the user side, but it is also SO GREAT from the developer perspective! I have taken advantage of the hooks for a couple of projects.
Comment #12
quicksketch@flamingvan: That looks like a good approach though not exactly and easy-to-write format, but hey, hierarchical lists are pretty hard. Even when you finish, I don't think we'll be able to include this directly in the Webform project, but I would love if I could reference it as another project (even just a sandbox) on drupal.org.
Comment #13
flamingvan commentedAssuming the project goes through I will absolutely put it up on drupal.org. I submitted a proposal for the project on Friday so we will see what happens. I will keep you posted.
Comment #14
flamingvan commentedI don't think I'm going to get the job :(
If anyone is interested in this I have an estimate all written up.
Comment #15
ayalsule commentedsub
Comment #16
bastiaan1321 commentedsub
Comment #17
camilo.mejia commented@flamingvan: I'm interested in continue your work. I have a client that need it. Please help me with any aditional info or progress that you have and I will try to make a module to solve this problem. Thanks.
Comment #18
flamingvan commentedHi Camilo,
Never really went anywhere with this. The client hired me to do some other work but not this jobs. See my post #11 above. I think that's the way to go.
Comment #19
quicksketchMarking this postponed, since I have no plans for direct Hierarchical Select list support in Webform. As said above a few times, this can be implemented as a separate module using Webform's hooks (hook_webform_component_info()). Even if it were implemented, it wouldn't be part of the main module.
Comment #20
quicksketchComment #21
than1337 commentedSorry if it's not the right place to ask my question. I'm new on Drupal.
I'm working on a module which will add a dependent dropdown in a webform element based on a select list which is actually populated by the hook_select_options_info .
Anyway, I have problems to make the thing work, I've tried with ahah and ajax API. Does anyone have a simple solution to make this kind of seelect list working?
I think if I have no solution until the end of the week I'll try to make it the traditional ajax/js way.
Thanks.
Comment #22
shanefjordan commentedthan1337 - take a look at the webform conditional module. It may help, depending on how complex of a solution you are needing.
You could create multiple select lists, then based on the main list option selected, display one of the other lists you have created.
Good luck,
Shane
Comment #23
than1337 commentedThanks, I'm working on it right now, it's juste what I was looking for. :)
I'm trying to figure out how how webform conditional is getting the first select list value. So I can make a dynamic option list on the same trigger, like hierarchical select would do.
Thanks again.
Comment #24
danchadwick commentedThese requests are for the -3.x branches, which won't receive futher development. While I see the desire for this, the lack of good support in core is a problem. I don't see this being added. Most users are using conditionals as suggested above.