DateTimePicker time selection jumping back to 0
Hello, yesterday i was worked with the DateTimePicker and i tried to use the minDate/maxDate on the non-native component, but after I added that function I observed that when I trying to change the time it always jump back to 0 and if i remove that function the time picker works correctly. Is this some kind of bug or the minDate/maxDate not working with the non-native DateTimePicker?
10 Replies
And also this is the component how I am using:
DateTimePicker::make('start_date')
->label(__('Start date'))
->default(now()->startOfDay())
->seconds(false)
->weekStartsOnMonday()
->required()
->maxDate(function (Get $get) {
return $get('end_date');
})
->closeOnDateSelection()
->native(false)
->displayFormat(config('localization.date_time_format'))
->live(),
Maybe because of
->live()
, without live() any differences? or try ->live(onBlur: true)
Without live() do the same and with live(onBlur: true) no differences
I just copy/paste your code, I didn't change any but I don't have your problem..
Maybe browser issue?
I forgot to mention that this problem only occurs when you are on the edit record page. On the create page works good. Can you try on the edit record page?
No problem as well..
What is your filament version?
Strange
3.2.88
Hey @wazkaz i had the same problem, so i figured it out!
The problem is with the javascript that filament uses so when you add a minDate(..) with time in it then it makes it available to the javascript but without pre-feeling the field, so then you are trying to increment from 0 to 1 it goes back to one because it validates to false and is clearing the state to 0:0:0. This is kinda right btw .. i know don't ask ..
Anyway a solution for anyone reading this is :
1. Pass only DATE in a datetime field for minDate() validation The problem with this is that is not validating the time any more (by it self)
2. Use afterOrEqual(..) in compination with above in order to validate a full datetime string. (if you just use this tho will be also fine but the dates will not be grayed out)
I hope i helped anyone from loosing 6+hrs from his life to solve this
If it’s a legitimate bug please submit a PR to fix it.