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

Ability to set default false value for checkbox fields #11

@iamvanja

Description

@iamvanja

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions