I am using your module to allow users to select a location
[Country] [Region] [City]

This works well but for a country that has no regions... or a region that has no cities no select is created. I see the reason behind this especially for taxonomy and such but what im proposing fixes my problem plus i think will improve taxonomy support.

Allow a form setting on how to handle when no values are returned for a depth. One possible way would be to "if enabled" always show a "Not Listed" option at the top of each select. This text should be configurable of course.
When the user selects that option the selects from that depth on slide in then back out again as input boxes.

Example: I select my Country and then the regions have no values so for my second drop down i get a not listed option with no other values. If I choose this not listed... then that select turns into two input boxes.

The reason it turns into 2 input boxes is because its assumed that if you dont have the region for a country, then you dont have the city either.

I think this also means some extra configuration options for what text to put inside the input boxes.. like [Enter Region] and [Enter City]. And if the depth of the inputs should go down to the end.

For taxonomy this allows some type of free tagging functionality.

What I have working is replacing selects with no options with input boxes. What I dont have working is the animation on the input boxes matching the animation on the original selects. This is obviously due to the js that grabs the selects and doesnt work with inputs. For someone who knows jquery this seems like an easy update which adds a great deal of functionality.

Let me know what you think.

Comments

agn507’s picture

I would also like to note that the reason this is important for me is to keep consistent format of country, regions, and cities.

For a city a user could enter the name "Mt. Morris" or the name "Mount Morris" but having one version in the select it increases the chances of not getting multiple versions of the same city name.

wim leers’s picture

While I understand your concept and like this method of user input, this is not something you'll find in the Hierarchical Select form element.

This module merely offers a new form element, the Hierarchical Select form element, which is another way of displaying an existing set of options that are ordered in a hierarchy. It can have various depths within the same set. It does not allow for the input of new "stuff", so just making the selects into empty input boxes isn't going to get the server side of this going to work: whatever you enter in the input boxes, isn't going to be saved.

Remember that this is supposed to be a general solution to the common problem of selecting a certain item in a hierarchy. It's not designed for input. And it's most definitely not designed to specifically suit the country-region-city case. So I won't be implementing this, nor will I accept a patch that implements it.

If you really, really want this, because it's more difficult than it might seem at first glance (especially if you also want it to work nicely when JS is disabled), is to create a new form element specifically for this usecase. You could either base it on the hierarchical_select form element type, just like hierarchical_select is based on select, or take whatever you want from this module.

One day, in Forms API 5 or 6 maybe (in Drupal 6 we're at FAPI 3), this stuff might become trivial, but now it's definitely not.

wim leers’s picture

Status: Active » Closed (won't fix)