Action modal form with many field to prefill
I have an action with modal form, initially i follow the documentation example to fill the form with default data, but now theres too many fields in the form, is there another way that gives less redundancy?
12 Replies
Can you share what you have? It would help to offer an alternative...
you could
$this->form->fill($this->record->attributesToArray())
but make sure your're not exposing any sensitive data to the frontendthanks, that works well, and how about for saving the updated data? for example currently i do it like so
$this->record->update($data)
?lol thanks, i felt dumb for not figuring that
refreshing the form doesnt seem to work the same tho
you can
$this->form->fill($data)
too, but the form should be already refreshed with the data you've typed in, no?not if i do
$this->refreshFormData($data)
noi mean, why do you need to refresh the form when the information is already updated?
idk ig bcs it doesnt look good to the eye cus when the modal is closed the view/page isnt automatically refreshed lol
Hi, have you found a way to automatically refresh form data after the Modal data is updated and closed? On my main form, I have a modal to update a related record, but the related record is not refreshed after the modal is done. Thanks!
you can use $this->fillForm() in the modal action() closure
thanks. but this didn't work for my case.