$this->getRequest()->getPost() return empty array in magento back end form submission

邮差的信 提交于 2019-12-04 03:15:45

Common error for all. You just need to add form key to your form. Just add this line below your form declaration.

<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />

Like this

<form action="<?php echo Mage::helper("adminhtml")->getUrl("demo/adminhtml_demo/demo");?>" method="post" id="custom-payment-form" enctype="multipart/form-data">
<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />

Add this. Now you can get parameters by $this->getRequest()->getPost().

you can get variable of post and get method in magento with $this->getRequest()->getParams(); getParams() method But if you want to get exactly some variable data then use getParam('id');

/magento/catalog/product/view/id/406/category/14
 $this->getRequest()->getParam('id')    // 406

$this->getRequest()->getParams(); //get all get and post variables  
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!