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:
```php DatePicker::make('release_date') ->live() ->afterStateUpdated(function (Set $set) { $set('issue_start_date', null);...
Jump to solution
12 Replies
toeknee
toeknee3mo ago
Aditya Khadka | Nepal
i need to disable all previous date from release date. @toeknee
toeknee
toeknee3mo ago
Stack Overflow
How to disable only weekends in Laravel-Filamentphp or disable all ...
I'm working on a Laravel project using Filamentphp My form has DatePicker and I'm unable to disable all Weekends days or disable all dates except the one I specify. DatePicker::make('issuestart...
Aditya Khadka | Nepal
@toeknee i dont know why but below codes is also not working. Forms\Components\DatePicker::make('issue_start_date') ->required() ->reactive()
->disabledDates([
// Disable dates before today 'before ' . now()->format('Y-m-d'), ]),
No description
toeknee
toeknee3mo ago
Looking here, Dan say's it's not supported: https://github.com/filamentphp/filament/discussions/6403
GitHub
How to disable only weekends or enable only multiple range of dates...
My form has DatePicker and I'm unable to disable all Weekends days or enable only multiple ranges of dates leaving other dates disabled Here is my code DatePicker::make('issue_start_date...
toeknee
toeknee3mo ago
you could just add a validation, if date is before X date altert, must be a future date.
LeandroFerreira
LeandroFerreira3mo ago
disable dates before today
DatePicker::make('issue_start_date')
->minDate(now())
DatePicker::make('issue_start_date')
->minDate(now())
?
toeknee
toeknee3mo ago
I knew something like that exists too ahahaha! Can't see wood through the trees.
Aditya Khadka | Nepal
Actually, I need to disable dates before the release date. Disabling dates before today wouldn't be a problem. @Leandro Ferreira Forms\Components\DatePicker::make('release_date') ->required() ->reactive() ->afterStateUpdated(function (Set $set, Get $get, $state, string $operation) { $releaseDate = Carbon::parse($state); $set('release_date_min', $releaseDate); }), Forms\Components\DatePicker::make('end_date') //in end date calender previous date of release date should be disabled ->required(), Okay i will implement this package @toeknee
Solution
LeandroFerreira
LeandroFerreira3mo ago
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'))
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'))
Aditya Khadka | Nepal
wow. thank you very much @Leandro Ferreira .
Want results from more Discord servers?
Add your server