Couldn’t find details within redwood documentation, but doesn’t work, now i’m not sure if its property name’s defaultValue and not something like defaultDate or something…
Essentially need to set the default value for DateField visible,
and possibly be able to format the value from its datepicker like 01-Jan-2022.
Please help or give me the proper link, thanx
3 Likes
Same issue I got trying to edit with the Form the Datefield/ Default value don’t work. Won’t auto fill the field with the Date as the defaultValue property seems a mess
I haven’t taken a look but looks like it’s solved on github
export const formatDateForInput = (value?: string) => {
if (value && value.indexOf('T') >= 0) {
return value.split('T')[0]
}
}
Helper function
Pretty sure I used ‘value’
ie:
<DateField
className="..snip.."
name={props.dateFieldName}
onInput={dateChange}
value={displayDate()}
/>
If you using controlled components you can use value and defaultValue for the uncontrolled. You still get the same issue if your displayDate function does not parse the object recieved
1 Like