How to create a reusable toggle button

Hello everyone, and congrats on the great forum and platform!

OBJECTIVE
My objective is to create a reusable toggle button, meaning a reusable element that acts as a toggle button.

The details of the toggle button are out of scope (it has a state, it changes color conditionally based on the state, etc…). The interesting bit is how to make this reusable. I do not want to change it everywhere in the app, but have a central location.

However, the boolean (yes/no) field that it toggles is not always the same, and should be generic.

PROBLEM

If I set the reusable element’s “Type of Content” to “yes/no”, it is not modifiable by binding, as seen in the following screenshots:

POSSIBLE SOLUTIONS

For the moment, the only solution I found is to wrap the “yes/no” field in a Thing, let’s call it “YesNoThing”, and pass the thing to the reusable element.

While this works, it adds complexity and a whole new DB thing with thousands of items in it (one for every “yes/no” field).

I’m quite sure there should be a better solution.

Thanks for your help,
Luca

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.