FilamentF
Filament2y ago
15 replies
Aditya Khadka | Nepal

Disable Previous Dates in End Date Picker - User Should Not Select Before Release Date

I'm trying to disable dates in the end_date picker so that users cannot select any date before the release_date using Filament's DatePicker. Here's what I have so far:

Forms\Components\DatePicker::make('release_date')
->required()
->reactive()
->afterStateUpdated(function (Set $set, Get $get, $state, string $operation) {
$releaseDate = Carbon::parse($state);
// Update the minimum date for the end_date based on the selected release_date
$set('release_date_min', $releaseDate);
}),

Forms\Components\DatePicker::make('end_date')
->required(),

What I'm trying to achieve:
Users should only be able to select an end_date that is equal to or after the release_date.
P
How can I properly disable dates in the end_date picker that are earlier than the release_date?

Thanks for any help or insights!
Solution
DatePicker::make('release_date')
    ->live()
    ->afterStateUpdated(function (Set $set) {
        $set('issue_start_date', null);
    }),
DatePicker::make('issue_start_date')
    ->minDate(fn (Get $get): ?string => $get('release_date'))
Was this page helpful?