If data is structured same then you can use one modal with ajax calls to populate that form (if you need more data) and edit it.
Best approach when using Popup Modals
Hello guys, I've been struggling with a good implementation when it comes to use popup modals, specially with forms in them, and laravel. Actually, it's more a general topic rather than just laravel, since it could apply pretty much everywhere.
I've come up with different solutions, but none of them seems to fully convince me, as they both have some drawbacks, maybe I'm missing an obvius one or I'm being too picky!
I've got the modal (bootstrap modal) on a partial view. First thing it came to mind is to include that view on the main page view, then just using js to show it. This would be good if there were only one modal per page, but if I've got for example a table with records and every single one of them has an edit button that triggers the modal so I can edit the item, makes it really inneficcient in my mind, since i would have hundreds of modals loaded in the view, because the include would have to be inside the loop. I've seen this approach very often though.
So the second thought would be using ajax in those cases, a controller method that simply returns the view with the item fetched, and then display it, to show validation errors after submit, a simple count($errors) would call that popup again, and it would display them. This one seems cleaner to me, but looks like a lot of calls and probably a bit slower on execution time.
Please or to participate in this conversation.