Hi people!
I have a data object with an attribute ‘status’, which is text (published or archived). I want to make a custom toggle that shifts between these two texts.
I’m willing to implement an onTap event to change the attribute content.
However when I try to put it with a formula I got: “this binding requires an inversible formula” and I can’t save the formula.
The problem is that this formula only works in one direction. When binding a 2-way value, the control also needs to natively know what to do with the new true/false value when the toggle is changed. If you could change the control to be a 1-way binding and then you handle the onChange event, you could do what you want. But alas, you cannot change it to a 1-way binding.
The only way I know you can do this is the following:
- Create a page variable statusBool of type true/false
- Bind your toggle value to this page variable statusBool
- On entrance to your page, set statusBool variable to the correct starting value using a Set Page Variable block using the formula data.selecionado.status == 'published’
- On the toggle control’s component OnChange event, convert the statusBool back to your status value using a Set Page Variable block with formula IF(pageVars.statusBool, “published”, “archived”)
Thanks for the answer.
I was hoping that there was a better and more elegant solution.
In the end, I changed my backend and send a boolean… 