Set Boolean Null via Radio

When binding a single-choice-radio to a boolean field it renders with options for Yes and No. Is it possible to add an option for null / empty? Or would it make more sense to use a different component / field type for this use case? We are working with the constraint of not wanting to lose existing boolean data.

My first thought is to use an object table with 3 columns: Yes, No, Null each with an action that sets the boolean accordingly and changes color based on the value of the field. This is a bit of extra work but should look really good from a UI standpoint. Any other ideas?

Great question. Some that immediately come to mind are that you could have a separate single-choice view variable that includes the null/empty option. However, in this case you will have to transfer those selections back to the existing boolean field and vice versa as you will be comparing the string “true” in the single-choice against the true boolean value.

Another option may be to have a button to “Clear Selection”, which would null out the current boolean value.

I am asking around to see if there are some other ideas for how to handle this with nice UI.

Another possible option would be to use the edit-select within an object-table column. To do so, you would need to define your options (“Yes”, “No” or “True”, “False”). An empty option is automatically added for edit-select. Then, you will need an on-change function to set the boolean field based on the string value the user selected and vice versa to display the value correctly in the edit-select options.
Example:


1 Like

Perhaps the simplest option of all would be to use the single-choice-dropdown component rather than the single-choice-radio component. This has the built in “de-select” option so you can always null out a selection.

Thanks Jaimie and Molly. Good ideas to consider. Going to mark this answered