dohomi/react-hook-form-mui

SwitchElement & CheckboxElement

Closed this issue · 7 comments

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

SwitchElement and CheckboxElement do not send data (undefined, empty) if they are not changed, clicked, and when the path is not straightforward ('some' - works, 'some.next.field' - does not work).

Expected behavior 🤔

Default value should be send with all paths.

Steps to reproduce 🕹

No response

any reproduction? Not sure I understand this task

Go here: https://react-hook-form-material-ui.vercel.app/?path=/story/switch-element--basic&args=label:Switch+Label

and set the property name (for example) like this 'switch.some' and click 'Submit'

then... you can see in Actions tab that value for this field is undefined. The value is set propertly when you click on the element.

PS. I use 6.8.0 version

I am not sure, a switch / checkbox is a boolean value, if ckecked the value true is sent, if not false. This seems for me expected like this

the name prop is a singular string - if you start changing the control name to something else you break how the Story is rendered - especially with dot notations. Without a reproduction I won't be able to assist as the switch works as supposed to work

closing for now without reproduction I can't understand the underlying issue.