Action to Fill New Record Form with Old Data

Hi eveyone! I am creating a resource that sometimes require redundant fields from an earlier saved resource of the same time. Is there a way to fetch old data from a specific record (based on user input) and fill the current form with that data? Thanks.
Solution:
For future reference and anyone else searching just use $livewire in a function and use $livewire->form->fill($data). It will fill whole form.
Jump to solution
7 Replies
krekas
krekas11mo ago
It is possible. You can create action button or do it on some select
tinkypinky
tinkypinkyOP11mo ago
I mean I can create an action and It can also fetch data from db depending on id etc but how to add/fill that data to current form fields?
krekas
krekas11mo ago
Using the $set livewire magic action. There are examples in the docs and some tutorials on laraveldaily.com for example where such is used. Just try something and come back with the code if it won't work for help
tinkypinky
tinkypinkyOP11mo ago
Is there a way to just fill whole of the form instead of using $set for individual fields?
krekas
krekas11mo ago
no. there's no other way to guess fields
Solution
tinkypinky
tinkypinky11mo ago
For future reference and anyone else searching just use $livewire in a function and use $livewire->form->fill($data). It will fill whole form.
Want results from more Discord servers?
Add your server