F
Filament14mo ago
Padrezz

Possibility to have nullable datepicker?

I have a 'Date of Death' field that should be nullable. Currently, the DatePicker defaults to the current date, and users have to clear it every time before saving. Is there a way to modify this behavior?
Solution:
Ok, got it. It's older project and I'm using carbon mutator, when it gets "null" value to parse, it will return current date, that's what I see on edit page. Thanks for pointing me to right way.
Jump to solution
4 Replies
Tieme
Tieme14mo ago
By default the datepicker is empty. Is it possible that you have a default date on the migration ? If not, can you share the code of your migration field and the datepicker?
Padrezz
PadrezzOP14mo ago
Inside DB is also NULL value Forms\Components\DatePicker::make('death_date')->label('Death date'), $table->date('death_date')->nullable(),
Tieme
Tieme14mo ago
Is this on creating a new record or updating a record? Because if i create a new record my default date in the form is empty only a mask of "dd/mm/yyyy".
Solution
Padrezz
Padrezz14mo ago
Ok, got it. It's older project and I'm using carbon mutator, when it gets "null" value to parse, it will return current date, that's what I see on edit page. Thanks for pointing me to right way.
Want results from more Discord servers?
Add your server