verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
93 stars 69 forks source link

Display inidividual dropdown field values based on field conditions #1828

Open philipschilling opened 2 months ago

philipschilling commented 2 months ago

What are you trying to do?

I have setup a form where the user can select from a dropdown a property location and based on the location can select a storage room. I have it setup but I am not happy with the solution because it is not scalable. At the moment, I have created for each location a separate dropdown field containing the storage rooms and the field is triggered by a field condition.

https://github.com/verbb/formie/assets/4956295/8880abf5-6c37-4a76-9b51-3e86b85e8684

Screenshot 2024-04-15 at 16 34 06 Screenshot 2024-04-15 at 16 34 23

What's your proposed solution?

Maybe there already exists a solution how this can be setup in a better way than I have done. If not, I suggest the following:

If you add a condition rule to a select field, show all field values with checkbox in the condition rule where I as user can select which values shall be shown when the condition is true. I need to add multiple rules (one per city) and just select the storage rooms which will be shown on the website frontend. Thereby, I can use one dropdown field for all storage rooms instead of a dropdown field per selected city.

It will make the system more scalable when adding new cities.

Additional context

No response

engram-design commented 2 months ago

Are the storage rooms unique for every location, or just some? If the former, there's no way around having a new field tied to the selected location. But you can have multiple conditions setup for a location, so if you have a set of storage room values that are applicable to multiple locations that can be setup in a single field.

By the way, when you pick an options-based field for conditions, you shouldn't need to enter the text specifically, you should be able to pick an option set in the field. Refer to the screenshot below:

image

I can't seem to replicate that on my end, and I can see the "Standort" field is a Dropdown.

We'll take a look at your proposed use-case, although that's a major change to how conditions work, where it introduces the ability to add conditions on individual options, not just the field. It's something we can look into though!

philipschilling commented 2 months ago
  1. Each room has a separate option to identify it by ID because each room is unique (size, etc.). So, your standard solution with shared option values will not work for me.
  2. It is strange that I cannot select from a dropdown the condition values. The field "Standort" is a dropdown field but the condition shows just a text field. I am using optgroup elements in my dropdown. Maybe this could have some influence?
engram-design commented 2 months ago

Fortunately, I could replicate this with your form setup from your support request, so I'll get that sorted.

The original issue still stands about being able to create conditions based on field options.