Remove invalid selections from MultiSelectField

As a follow-up to this question, I need help with the following situation:

I have a MultiSelectField with options being dynamically determined (with a callback function). Every time, when the options change so that they don’t include the current selection, the user gets the “Field contains invalid value” error.

image

Every thing else freezes. Currently, there is no way to remove the invalid values from the selection. I’ve tried a work-around with a SetParamsButton (as suggested in the mentiond community question) to help the user clear out invalid values, but the button gets frozen and it does not work.

I have also tried setting the values via Entity.set_params() (inside the callback function just before returning the new options), but that would only work if the user saves the changes and reloads the page (sometimes after 2x reload for some reason)

This behaviour is really frustrating for the users and we get lots of requests from our users to fix it. I’ve also read a couple of other community questions regarding setting the value for MultiSelectField/OptionField/…. Or default to select all, etc…

Is there currently a way to deal with this behaviour that I’m not aware of?
If not, can a feature be added so that invalid values can be removed from the selection in a propper way?

I would really appreciate it.

Hey @Sina ,

I don’t think there’s a real clean way to do this right now, as this is also (partially) intended behavior.

Default values are only used upon Entity creation, and set_params() does indeed only work on the backend, not the frontend.

If you have only a few options, you could potentially work with visible instead of options, and add a few MultiSelectFields, but I understand this not preferred.

Mostly, I’m curious about:

What do you mean here?

1 Like

Hi @rvandijk,

Thank you for your quick response! :smiley:

This is what I mean:

image

I think this is also intentional!? :person_shrugging:

Regarding the visibility, I have tens of possibilities and combinations of them. I could create the MultiSelectFields dynamically but there will be many invisible instances of MultiSelectField. How is the workload handled then? Do the invisible fields get skipped and not evaluated?

In any case, I would really like to see improvement on this behaviour and I’ll be more than happy to think along or co-operate on this.