Autofill fields from url

hey, is there a way to autofill fileds from the url? I have created this action which links to the Create Page of a resource, I want to have a few fields prefilled, depending on the action. Here is what i tried, want to fill the field named iban with the value DE90BLABLA
return Action::make('quick_create_assignment')
->label('Quick Create')
->url(fn ($livewire) => AssignmentResource::getUrl('create', ['iban' => 'DE90BLABLA']]));
return Action::make('quick_create_assignment')
->label('Quick Create')
->url(fn ($livewire) => AssignmentResource::getUrl('create', ['iban' => 'DE90BLABLA']]));
9 Replies
Dennis Koch
Dennis Koch2y ago
You should be able to access the data via the Livewire component: ->action(fn ($livewire) => do stuff with your component)
Quadrubo
QuadruboOP2y ago
but in that context $livewire is the current component and i want to modify data on the page I'm linking to. The Action is on the TransactionResource and I want to prefill data in the form of the AssigmentResource
Dennis Koch
Dennis Koch2y ago
Ah sorry. I thought you want to auto fill from a response. In that case. Pass your data as query params and retrieve them on mount() of the page
Quadrubo
QuadruboOP2y ago
ah okay so no native way to do it, thank you very much!
Dennis Koch
Dennis Koch2y ago
Nope. Maybe it's not mount but mutateDataBeforeFill() where you should add the data
Quadrubo
QuadruboOP2y ago
If i close this post, will this still be available to see for others? or what should I do, never worked with these help threads
Dennis Koch
Dennis Koch2y ago
I'll close it. It will be moved to the old posts for search.
Quadrubo
QuadruboOP2y ago
ah okay it needs to be done in mount(), mutateDataBeforeFill() is only called on the EditRecord Page got it working thanks
toeknee
toeknee2y ago
Yep it will, I've closed it for you now. It just marks it as old. And it'll still be openable.

Did you find this page helpful?