Hi Everyone,

I am using widgets to create a form step 1 and step 2, put date picker to select with 7 days only from tomorrow onwards and validate the field is it with 7 days. After some days i try to view the order still validate the delivery date and does not allow me to the next step. how to resolve this?
15 Replies
Dennis Koch
Dennis Koch6mo ago
It's hard to follow. Please add some code and maybe some screenshots
Sureshkumar
SureshkumarOP5mo ago
Sorry for the delay reply $minDate = Carbon::now()->format('Y-m-d'); Forms\Components\DatePicker::make('deliveron') ->native(false) ->label('Deliver On') ->required() ->minDate($minDate) ->maxDate(Carbon::now()->addDays(7)->format('Y-m-d')), I put in the order record creation. whenever view the order record prompt info.
Sureshkumar
SureshkumarOP5mo ago
No description
Dennis Koch
Dennis Koch5mo ago
whenever view the order record prompt info.
So when you press "Next"? I think that's the indented behaviour. I think you should create a separate view for viewing the records
Sureshkumar
SureshkumarOP5mo ago
If Edit also same.
Dennis Koch
Dennis Koch5mo ago
Sure makes sense. Forms have validation. Use a ViewAction if you don't want this or remove the validation
Sureshkumar
SureshkumarOP5mo ago
I need to restrict the users to place a order with in week or few days.
Dennis Koch
Dennis Koch5mo ago
Then use a ViewAction for viewing.
Sureshkumar
SureshkumarOP5mo ago
what about edit? if comments the orders it would not allow right.
Dennis Koch
Dennis Koch5mo ago
Then you should only validate on create?
Sureshkumar
SureshkumarOP5mo ago
Yes
Dennis Koch
Dennis Koch5mo ago
You can use a Closure for the validation rule. Something like this could work. Same for minDate
->maxDate(
fn ($context) => $context === 'edit'
? null
: Carbon::now()->addDays(7)->format('Y-m-d')
)
->maxDate(
fn ($context) => $context === 'edit'
? null
: Carbon::now()->addDays(7)->format('Y-m-d')
)
Sureshkumar
SureshkumarOP5mo ago
Still not working.
Dennis Koch
Dennis Koch5mo ago
I didn't validate the solution. Check whether context is actually edit I can't help you with that response
Sureshkumar
SureshkumarOP5mo ago
OK I will try thanks
Want results from more Discord servers?
Add your server