How to disable every other dates except one date in datepicker ?
I want to disable all the dates in datepicker input field except one date by setting it as default, how can i achieve this functionality ? default doesn't seem to be working.
Forms\Components\DatePicker::make('from')
->default(fn ($get) =>($get('min_date')))
->hidden(fn ($get) => (int) $get('farmer_id') == NULL)
->required(),
7 Replies
i kind of achieved this by setting minDate and maxDate to the same date. 🎉 Figured this hack after asking the question.
But the user still has to select the date, any way to make it selected ?
Just use default(now()) or something
Or whatever the date would be
@andrewwallo That works for now() , but not for ($get('min_date')) .
Well I’m not even sure where that is coming from and even if a default value can be hydrated from the state of another field. If you want to do that just set() the state of the select from the other component
@andrewwallo how to hydrate the default value when another value is changed ? Thanks for your time 😀
Use on the other component:
->reactive()
->afterStateUpdated(static fn (callable $set, $state) => $set(‘from’, $state))
Depending on your date display you may need to format the get value with a strtotime