AGuyTryingToCode Posted February 6, 2023 Share Posted February 6, 2023 Hi, I have created a module where a form is added to the admin view order page with: public function hookDisplayAdminOrderSide($params) The form posts data to the same url: <form method="POST" action="#"> I then use the hook "hookDisplayAdminOrderTop" to capture the post data and submit to the API on the page reload. I then collect the results of the api and assign it to $result. This then allows me to echo if the submission worked etc This all works fine. However, I'm pretty sure this is not the correct way to do this with Prestashop. Usually with a form I would send the user to another page e.g. <form method="POST" action="/submit.php"> Then on that page once the data has been submitted, redirect the user to a confirmation page. Whilst what I have done is working, what is the correct way to do this with prestashop (p.s. I'm new to Prestashop, this is my 1st module) so try and keep the advice easy to follow? I looked at the other forms on the page e.g. status update form and private note form, they all seem to post to the same url but with a slight change e.g. index.php/sell/customers/2/set-private-note index.php/sell/orders/2/status index.php/sell/orders/2/send-message I'm assuming the "set-private-note" and "status" etc are linked to some form for submission form in the PS back end. Finally, on a second note, if you create a 2nd php file in the module root folder, what needs to be added to keep this secure e.g. so someone outside of the admin can't run it etc? Any help would be greatly appreciated. Thanks in advance Link to comment Share on other sites More sharing options...
AGuyTryingToCode Posted February 17, 2023 Author Share Posted February 17, 2023 BUMP, can anyone point me in the right direction on how to use a form in the admin area, post the data then re-display the same page? Link to comment Share on other sites More sharing options...
ps8modules Posted February 19, 2023 Share Posted February 19, 2023 Hello. You need to define exactly where you want your button to be, for example in the picture. What other buttons do is twig, controller and route action. It's easier to use javascript and ajax in your module. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now