When choice element is hidden, it doesn't reset its value

Hey here is my use case:

I have a form allowing user to add an item to a list.
This item should be categorised correctly.
I have a table for items, with column to enter the category data (Category 1, Category 2, Category3)
To categorise the item, user will use the choice element.
Next choice element doesn’t appear if nothing is selected in on the last choice element

I have three level of categories.

    1. A;B;C

The category displaying on screen is filtered by the selection of the precedent choice. Ex.: if user select 1.A he will then be able to select only related categories for 2. : AA;AB;AC etc…

User now make his selection: 1. A, 2. AB, 3. ABB

User hasn’t clicked on submit yet

User change his mind and go back to 1., select B and click on submit.

Problem: Now I have a row for this item categorise as 1.B 2.AB 3.ABB
As the user selected 1.B, I would like 2. and 3. to be only related to the first category or empty.

Any solution?

A multi step form might be your best option for this. That would make it so users can’t change parent category responses after selecting sub categories.

I’m curious to hear what others offer for this. Just yesterday I was thinking of something similar and a multi step form isn’t always desirable. I think it’s a common general case of wanting validation conditions on a form’s submit button. Really you would like somewhat of an action on the choice component to clear the other choice components… but at a minimum you want to ensure the variables being submitted fit certain conditions.

My case was simpler, of having a form with a start and end time, and wanting to enforce an end time after the start time.

The simplest, but incomplete, solution is to add a prompt to the user to change the invalid selection. Such as a hint that’s conditionally displayed. “Error: Please update your choice.” Something like that. But, that doesn’t ensure the user complies.

A more thorough option I thought of was to use the hints above, combined with the following. Create a boolean column in your data to mark each row validated or not. Set up some columns to validate your data. Then use a post submit action that checks the validation logic columns, and if the data meets the needed conditions, it marks the row’s validation boolean true. In the post submit action, if the conditions are not met, it does not mark the row validated and instead opens the row’s edit screen. Put the same post submit action on the edit form. This basically keeps people stuck in the form, until they comply with the hints. And wherever you’re using or displaying the form data, only use/display it when it’s validation boolean is true.

This is still isn’t a great UX, but I don’t think you can get a choice component to reset based on changing another one.

Your answer is quite interesting, thanks.

I was kind of hoping I wasn’t reaching a dead end in terms of solutions. This would have meant the only solution is to trick it with boleans and made up built.

Now it’s getting even more complexe since I’m going to have 5 subcategories. Certain categories reach level 5 and some only level 3. Meaning if the user fill it to the end and change his mind, I’ll have data in place of empty cells.

I was thinking of running it with row ID making the whole row a category because at the end, the last category chosen can tell you the whole related categories. Might be something I’ll investigate.
It also means in the item data table, I’ll have only one column for category and will use relations and lookup to show its parents.

Also I saw a second problem to add to the first, if the user choose a subcategory path that end to level 3, the level 4 will appear empty on the screen which is good, but the title stay, which is not good… I tried to remove to title entirely but the «required» mention stay on screen as well. I didn’t find yet a way to make it disappear if nothing can be selected.

Will keep you updated

Also anyone is welcome to help

Interesting thought to make the sub category choices come from a relation. This would mean you’re just choosing from the related subcategories, rather than a filtered list. Perhaps in doing this, it might work as you want and un-choose sub category choices with a parent choice change. I’m not sure… I’d like to test this out tonight but right now it’s time to fetch the kids :stuck_out_tongue:

I think your best solution is:

  1. Child choices are filtered to only show valid options based on the selection of parent.
  2. Child choices that are no longer valid after user changes a parent choice and then submits form, are cleared with a post submit action.

My quick thought of using the choice source coming from a relation of valid choices given the parent selection didn’t work… could work in multistep form, but not single form. That’s because the source was coming from the data table, not the being-filled-out data.

I think your latest idea is like saying you’ll collect only the street address, and from that, also know the city, state, and country. That sounds fine at first thought, so long as any end (street address) exists in only one possible path. I think you’ll run into the same problems though… if some paths end at level 3 and others at level 5… if the user goes down to level 5 and then goes and changes 3 and submits, you’ll still have the data from level 5 written and presumably think that was the selection intended.

1 Like