informative
informative copied to clipboard
Ability to set default false value for checkbox fields
I need a way to turn empty string into '0'
or at least 0
for checkboxes.
Currently I am mapping those values on submit, however it requires to keep track of which fields are checkboxes (working with big forms). To avoid keeping track of field types, I thought to look for checked
property as a way to differentiate checkboxes from other fields, but the only thing available is formState.fields[name].props.checked
which are initial props and do not update.
Ideally, this would be dealt with on a field instance and not submit. Also looked into creating a separate CheckboxField component, but it seems that ''
is hardcoded in the Informative internals, so dealing with it there is too late.
How about an uncheckedValue
prop?
What would be the best way to do this?
Thanks
Yea I'm gonna have to think about this and try a few things out. Your idea for a prop for the unchecked value might pan out