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:Jump to solution
```php
DatePicker::make('release_date')
->live()
->afterStateUpdated(function (Set $set) {
$set('issue_start_date', null);...
12 Replies
So you will want ->live() not reactive() <- this is v2.
And disable the dates with:
https://filamentphp.com/docs/3.x/forms/fields/date-time-picker#disabling-specific-dates
i need to disable all previous date from release date. @toeknee
See:
https://laraveldaily.com/post/filament-date-picker-disable-dates-with-conditions
and
https://stackoverflow.com/questions/76170205/how-to-disable-only-weekends-in-laravel-filamentphp-or-disable-all-dates-except
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...
@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'), ]),
->disabledDates([
// Disable dates before today 'before ' . now()->format('Y-m-d'), ]),
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...
You could try:
https://filamentphp.com/plugins/coolsam-flatpickr
with
https://flatpickr.js.org/examples/#disabling-ranges-of-dates
Filament
Flatpickr by Sam Maosa - Filament
Use Flatpickr as your datepicker in the Filament Forms and Panels
you could just add a validation, if date is before X date altert, must be a future date.
disable dates before today
?
I knew something like that exists too ahahaha! Can't see wood through the trees.
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
wow. thank you very much @Leandro Ferreira .