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
pratik
pratikOP2y ago
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 ?
Andrew Wallo
Andrew Wallo2y ago
Just use default(now()) or something Or whatever the date would be
pratik
pratikOP2y ago
@andrewwallo That works for now() , but not for ($get('min_date')) .
Andrew Wallo
Andrew Wallo2y ago
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
pratik
pratikOP2y ago
@andrewwallo how to hydrate the default value when another value is changed ? Thanks for your time 😀
Andrew Wallo
Andrew Wallo2y ago
Use on the other component: ->reactive() ->afterStateUpdated(static fn (callable $set, $state) => $set(‘from’, $state))
toeknee
toeknee2y ago
Depending on your date display you may need to format the get value with a strtotime
Want results from more Discord servers?
Add your server