DatePicker value if DB field is null

I have a DatePicker component in a DonorsResource form, that lets you chose a birthdate for a new donor. However, this field is optional. When the column is null, and you chose to edit a donor, the DatePicker has the date 01/01/1970 pre-filled. Is there any way, in this case, to assign it the default "dd/mm/yyyy" that's present in the "New Donor" form?
Solution:
You are passing a null value which is trying to be formatted with the datepicker, which is in the past. Try adding ->nullable() to it and failing that, ->formatStateUsing(fn($state) => $state ? $state : '')
Jump to solution
2 Replies
Solution
toeknee
toeknee14mo ago
You are passing a null value which is trying to be formatted with the datepicker, which is in the past. Try adding ->nullable() to it and failing that, ->formatStateUsing(fn($state) => $state ? $state : '')
valentin_morice
valentin_moriceOP14mo ago
Second solution worked, thank you!
Want results from more Discord servers?
Add your server