Hey guys, how challenging would it be to create a condition that, based on a previous select list selection (condition), would cause a second select list to display a subset of options taken from the superset that was configured with the component?

This approach seems like it would maintain the integrity of the Drupal feature that helps protect against attacks to the site by ensuring that select component options selected by the user always match one of the options configured with the component when the form was created for display (avoids the "illegal choice" issue). As well the approach seems like it would meet the needs of several different use cases that have been brought up over the years.

Our Use Case:
In a Request For Use form for a performing arts center, the customer would first select which Venue they desire to use (e.g. Theater, Main Hall, Lobby). Each venue requires a second select list of Technical and Equipment options that are somewhat similar across each venue but with important differences.

  • The superset of options for the Technical and Equipment select list is: Tables, Chairs, Platforms, Grand Piano, Sound Board in Audience, Percussion, Upright Piano, Podium, Pipe Organ, Capurso Grand Piano, Bistro Tables, PA System.
  • If the customer selects Theater as the Venue the Technical and Equipment select list presents the subset of options: Tables, Chairs, Platforms, Grand Piano, Sound Board in Audience, Percussion, Upright Piano.
  • If Main Hall is selected as the Venue then the Technical and Equipment select list would present a slightly different subset of options: Tables, Chairs, Podium, Pipe Organ, Grand Piano, Capurso Grand Piano.
  • If Lobby is selected as the Venue then yet a different subset will be presented in the Technical and Equipment options list: Tables, Chairs, Bistro Tables, PA System

The idea uses a unique and simple approach and is slightly similar to https://www.drupal.org/node/1208816. Although there wasn't a lot of traffic for that issue, judging from the number of people who write their own code to make this feature happen, it isn't a niche case and seems like it is a reoccurring problem that is looking for a solution (Google: drupal webform dynamic select based on previous selection).

Comments

srutland’s picture

Issue summary: View changes

Added formatting

DanChadwick’s picture

I'm happy for you to post further implementation details and post (or sponsor) a patch. Absent that, I don't plan to work on this myself.

DanChadwick’s picture

Status: Active » Postponed (maintainer needs more info)
srutland’s picture

Understandable position Dan. With your knowledge of the code and db, do you think it's feasible and how monumental might be the task? Can you think of any overarching considerations we should account for such as where to store the conditional Options list and how to check it against the component's list of Options? I have been thinking about the UI for the conditional(s) and how that might work: e.g. if a component for Show/Hide is a Select Options then display beneath it a selectable list of its Options. I'm wondering how/if this would work with thousands of options. Our scenario involves only a handful. As I'm not a coder, but laughably moving that direction (I focus on App config, UI, and QA), I'll check into the possibility of having one of our student developers create it. Any advice/direction you can lend would be appreciated. Thanks.

DanChadwick’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

You have a specific problem so I'd solve it with specific custom code. You can load additional jQuery setting containing a map of what options (resources) are available for what source key (room key). Then you'd write some additional jQuery that would disable options that aren't available for that room.

We don't supply custom programming support in the issue queue. If you need more help, try the forums, IRC, Drupal Answers, or a paid developer. Good luck.

srutland’s picture

@DanChadwick, thanks for considering this feature request. Actually we will use it regularly across our secureforms services. As time permits we're going to make a patch and contribute it as there seems to be enough user scenarios in the community to justify this as part of the Webforms family. Cheers