Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lost the formatting method call in checked field getter #858

Closed
bin1357 opened this issue Sep 21, 2020 · 4 comments
Closed

Lost the formatting method call in checked field getter #858

bin1357 opened this issue Sep 21, 2020 · 4 comments

Comments

@bin1357
Copy link
Contributor

bin1357 commented Sep 21, 2020

Are you submitting a bug report or a feature request?

bug report
Lost the formatting method call in getting the checked field value
https://github.com/final-form/react-final-form/blob/master/src/useField.js#L221
it is impossible to make a checkbox that would switch between two true values. For example 'on' and 'off'

What is the current behavior?

it is impossible

What is the expected behavior?

it is possible

Sandbox Link

https://codesandbox.io/s/keen-oskar-l1vku

@bin1357
Copy link
Contributor Author

bin1357 commented Sep 21, 2020

@bin1357
Copy link
Contributor Author

bin1357 commented Sep 21, 2020

<Field
    name="employed"
    parse={(t) => (t ? "on" : "off")}
    format={(f) => (f === "on" ? true : false)}
    component="input"
    type="checkbox"
/>

@ArturKp
Copy link

ArturKp commented Oct 4, 2020

I'm not familiar with the codebase, so can't say anything about the code changes, but this seems to also fix my odd usecase, which I was expecting to work.

parse={t => t ? null : 1}
format={f => f === null}

Checked: null
Unchecked: 1

@erikras
Copy link
Member

erikras commented Oct 21, 2020

Published fix in v6.5.2.

@erikras erikras closed this as completed Oct 21, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2021
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

3 participants