Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Ability to set default false value for checkbox fields #11

Open
iamvanja opened this issue Jun 14, 2018 · 1 comment
Open

Ability to set default false value for checkbox fields #11

iamvanja opened this issue Jun 14, 2018 · 1 comment

Comments

@iamvanja
Copy link
Contributor

iamvanja commented Jun 14, 2018

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

@bradwestfall
Copy link
Owner

bradwestfall commented Jun 22, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants