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