Hi, I created a custom modal to submit a form to save to the database. The form itself works as intended, but after resolving the modal it redirects to a page that only shows a json array. Looking at the network tab of the browser’s development tools shows that the page is a application/json
response.
With debugging I found that the controller method that saves the data to the database runs the code return $response->withJson([], <status code>);
, where status code depends on if the data on the form was correct (400 if not, 200 if yes); and if I modify the array in this line its changes reflect on what appears on the page.
While processing the form on the server side in the controller, I add alert messages to be shown on the page, and after the empty page appears and I refresh those alerts appear on the page from which I open the modal.
This error doesn’t appear on other modals that come with the framework.
Thanks in advance.