Calender does not work with React-hook-form #2616
-
Calendar does work with react-hook-form. Component usage: <Controller name="birthDate" control={control} rules={{ required: 'Birthday is required.', }} render={({ field, fieldState }) => ( <> <label htmlFor={field.name} className={classNames({ 'p-error': errors.birthDate, })}> Date of Birth <Calendar id={field.name} maxDate={maxDate} dateFormat="dd/M/yy" className={classNames({ 'p-invalid': fieldState.error, })} onChange={(e) => field.onChange(e.target.value)} /> {/* Mobile */}
Default values from console log: Useform' Should this work with react-hook-form like InputText does? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
User error |
Beta Was this translation helpful? Give feedback.
-
By setting a default date I can ensure the date has a value and can get round the validation rule of a required entry. |
Beta Was this translation helpful? Give feedback.
By setting a default date I can ensure the date has a value and can get round the validation rule of a required entry.