Magento: Submitting form in admin redirects to dashboard
When trying to submit a form which is created in admin, it redirects to dashboard no matter how much you try. I faced this problem and tried many things but without any luck. Everything was running, for file upload I had enctype=”multipart/form-data” in form, checked the form action through firebug and run it directly in browser URL which was also going good. After so much frustration, googled the problem and found that I was not the only one to face this problem.
Finally, got one forum where I found the solution to this problem. In Magento, when submitting the form, you need to have one extra hidden field, with name “form_key” which should have form’s key value from session. Here is the line of code, which helped me in posting form successfully.
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /> |
Hope this helps some frustrated mind 🙂
11 Comments
Leave a comment
Welcome to my Blog
Certifications
Honor
Recognition
Contributions
Categories
- Apache (2)
- ChatGPT (1)
- Domain name (2)
- eCommerce (2)
- htaccess (1)
- Humor (3)
- Instagram API (1)
- jQuery (4)
- JSON (1)
- Linux (10)
- Magento (142)
- Magento admin (58)
- Magento Certification (5)
- Magento error (13)
- Magento frontend (68)
- Magento Imagine (2)
- Magento Interview (5)
- Magento Master (2)
- Magento2 (10)
- Mobile (1)
- MySQL (7)
- OpenAI (1)
- OroCRM (2)
- Performance (2)
- PHP (8)
- Prototype JS (3)
- Security (4)
- Wordpress (3)
- XML (2)
I was using custom form in magento backend after a long time, the action URL was correct but still it was not submitting the form and redirect it to the dashboard. after trying for an hour then I gave up and searched in google and found this post, then I remembered that I was missing this piece of the puzzle.
Thanks alot, it really helped.
Beautiful! Single line solve the problem.
Thanks alot!
Thanks dude… 🙂
You made my day…
Regards
Dinesh
Where do I put that code?
I need to redirect to my controller action from a .js file. hw can i do this? i am facing the same problem. Though i typed my action name in the browser url also not working. whats wrong with my controller?
Make sure you are passing form-key along with url if redirecting in admin. If that too doesn’t work, check if you have “Action” suffix in the controller action method name.
I checked everything kalpesh, but not working
Excellent. I was going crazy with this item.
Work fine. Thanks alot!
thanks dude i was going to lose it
I met same issue from magento admin. So I added one line code you posted in my custom form.
My custom form including upload file function.
when I upload small file, it is working well. but when I try with big file, it still redirecting to dashboard. also not saved data.
do you have any idea about my issue?
your post is always very informative thanks.