Sep 13, 2012

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 🙂


  • 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…


  • 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.

Leave a comment


Welcome to my Blog

Kalpesh MehtaHelping Magento developers in their day-to-day development problems since 2011. Most of the problems and solutions here are my own experiences while working on different projects. Enjoy the blog and don't forget to throw comments and likes/+1's/tweets on posts you like. Thanks for visiting!




Magento top 50 contributors

Magento top 50 contributors