final-form / react-final-form

🏁 High performance subscription-based form state management for React
https://final-form.org/react
MIT License
7.38k stars 480 forks source link

input[type=checkbox] should behave as select[multiple] #90

Closed brikou closed 6 years ago

brikou commented 6 years ago

Are you submitting a bug report or a feature request?

I don't know, problably a bug... or a feature :)

What is the current behavior?

When using using input type="checkbox" we only can get a boolean.

https://codesandbox.io/s/n4ppqq63n0

What is the expected behavior?

In this example, I really want it to behave as the select with multiple option.

Sandbox Link

What's your environment?

Other information

Appart from this, lib is perfect :+1: keep the good work

crobinson42 commented 6 years ago

I'm in the same boat as @brikou doesn't look like there's much testing on checkbox fields, yet.

https://github.com/final-form/react-final-form/blob/95a4c58c9fabbbbca4b892f3c8eb06eab8f214a2/src/Field.test.js#L462

erikras commented 6 years ago

Heh. I wrote a long informative comment here, but then my computer crashed.

In short, I considered your request and found it fairly easy to implement.

mohadib commented 6 years ago

@erikras any idea when this will be released (pushed to npm repo) ? Thanks.

erikras commented 6 years ago

Probably today. I want to knock out a couple of other things and then publish.

crobinson42 commented 6 years ago

@erikras you rock!

erikras commented 6 years ago

Fix published in v2.2.0.

brikou commented 6 years ago

@erikras thank you

erikras commented 6 years ago

This functionality has been added to the Simple Example. It's pretty easy!

borm commented 6 years ago

Hi, how validate it? As example all checkboxes should be checked

erikras commented 6 years ago

@borm Huh? Can you explain further what your requirements are?

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.