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
krekas5mo ago
It is possible. You can create action button or do it on some select
tinkypinky
tinkypinky5mo 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
krekas5mo 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
tinkypinky5mo ago
Is there a way to just fill whole of the form instead of using $set for individual fields?
krekas
krekas5mo ago
no. there's no other way to guess fields
Solution
tinkypinky
tinkypinky5mo 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.