Closed unoriginalscreenname closed 6 years ago
use the formApis setValue to set a value. You can save an reference of the formApi by using the getApi prop.
@ericmcgregor can i close?
use the formApis setValue to set a value. You can save an reference of the formApi by using the getApi prop.
How about a simple example base on html code below ?
<input type="checkbox" name="cb[]" value="Item 01" checked />
<input type="checkbox" name="cb[]" value="Item 02" checked />
<input type="checkbox" name="cb[]" value="Item 03" checked />
<input type="checkbox" name="cb[]" value="Item 04" />
<input type="checkbox" name="cb[]" value="Item 05" />
<input type="checkbox" name="cb[]" value="Item 06" />
=> Desire value: ["Item 01", "Item 02", "Item 03"]
and also please add example for multi-checkboxes in docs as well, example react-hook-form has significant clear docs more than this !
@VQH-cmd do you want to add a checkbox in the simple example? I'll be happy to review your PR :)
Let's say i have an array of items, and i'd like to use a checkbox to push their Id's to the form's values... how would i get the checkbox to add a custom value other than 'true' to the array? This seems like it'd be a common use case.