RadioGroup/RadioButton React components doesn’t support proper bindings to boolean values in a form, or at least I don’t know how to do it properly.
The value property of RadioButton is not accepting booleans, so I have to set the value for them as follows:
<RadioGroup label="Active" {...field(model.active)}>
<RadioButton label="Yes" value="true" />
<RadioButton label="No" value="false" />
</RadioGroup>
But, setting the record that contains an active
property to the form doesn’t change the selection of the RadioButtons.
If I change the editor component to a Checkbox, it properly select/unselect the checkbox accordingly (so I assume the form binding doesn’t have a problem).
I assume that this behavior comes from the fact that it cannot match the boolean value of true
or false
to the string literals of "true"
or "false"
, but having the RadioGroup and RadioButtons, setting the value to the bound object is working fine (binding works somehow in one way), it’s a bit confusing: Why is it actually working?
So I have these two questions:
- Is there a way to have the two-way binding work properly for RadioGroup/RadioButton and booleans? Or am I missing a point?
- What prevents us from having an in-memory data provider for RadioGroup and CheckboxGroup so that the developer doesn’t have to deal with low-level on-change events?