Revert ToggleColumn State after failed Validation
Hi there,
I have a
ToggleColumn
in a list view, and I’m facing an issue. I’ve added a validation rule, and based on the validation result, I want the toggle to revert to its previous state if the validation fails. This way, the user won’t be confused by seeing an invalid notification while the toggle state has changed.
I know this behavior works in the edit or create record views, but I haven’t found a solution for the list view yet.
Any hints or guidance would be greatly appreciated!6 Replies
can you provide some code, i believe you can use
beforeStateUpdated()
and revert itThis is the column.
I tried
beforeStateUpdated()
but wanted to use rules(), so the record is not updated if the validation fails.
As I understand from the documentation
`
The life cycle hook can manipulate the state before or after the record is saved to the DB. But a re-rendering or state binding isn't possible in the list view. May be I don't see the point, yet.
I also tested this
`
Just to see if the hook manipulates the state, but still the record is updated with the user input, instead of my manually assigned value.This maybe very different from what you try to achieve, but here it goes
In my case, if recomCount is 15, then it display noti about limit..
I see, I'll try this approach. Thanks mate! Will give an update here as soon I have progress.
Yes sure, and please try to use
throw new Halt()
to see whether it prevents or not cause my project is a little old, I don't want to dig any deeper.. 😆Update: throwing the Halt() exception doesn't work. The
ValidationException
kept the toggle old state! Thanks @Vp