I have a simple requirement that upon a form being loaded, I want to set the value of a checkbox - but I am unable to do so with defaultValue in useForm or setValue.
This is the snippet of code for the custom input check box component
<Controller
control={control}
name="cb-1"
defaultValue={true}
render={({ field }) => (
<CustomInput
inline type='checkbox' id='cb-1' label='Checkbox'
/>
)}
/>
As above, I even tried setting a default value of true but the checkbox is never checked.
I also tried:
<Controller
as = {<CustomInput inline type='checkbox' id='floodLit'
label='Flood Lit?'
onChange={ e => { console.log('blah') }}/> }
control={control}
name='floodLit'
/>
and this too
<CustomInput inline type='checkbox' label='Flood Lit?' {...register("floodLit")}/>
Nothing works for me !!
I thought that using controller is the right way to register 3rd party components but I am not able to get this work at all, any help would be appreciated. Even a
setValue('cb-1', true)
is not working.
I know I am missing something basic but I am struggling with this and would appreciate any help possible
Ananth