forms – $this-> getRequest() – > getPost()在magento后端表单提交中返回空数组

我正在创建一个magento自定义管理模块和一个表单.我想更新此表单但不更新.在Controller中,在SaveAction()下,我打印$this-> getRequest() – > getPost()并获取空数组.请帮我.下面的代码表格偏差..
protected function _prepareForm() {
    $form = new Varien_Data_Form(array(
                'id' => 'edit_form1','action' => $this->getUrl('*/*/save',array('id' => $this->getRequest()->getParam('id'))),'method' => 'post','enctype' => 'multipart/form-data'
                    )
    );

    $form->setUseContainer(true);
    $this->setForm($form);
    return parent::_prepareForm();
}

并创建一个来自字段集的类似

protected function _prepareForm() {
    $form = new Varien_Data_Form();
    $this->setForm($form);
    $fieldset = $form->addFieldset('qbanner_form',array('legend' => Mage::helper('qbanner')->__('Art  information')));

    $fieldset->addField('name','text',array(
        'label' => Mage::helper('catalog')->__('Product'),'required' => false,'name' => 'name',));
    $fieldset->addField('artist_name',array(
        'label' => Mage::helper('catalog')->__('Artist Name'),// 'name' => 'artist_name','value' => Mage::helper('catalog')->__('Art Name value'),));
    $fieldset->addField('bca_status','select',array(
        'label' => Mage::helper('catalog')->__('Art status'),'name' => 'bca_status','values' =>$this->_getAttributeOptions('bca_status'),));
    $fieldset->addField('reason','editor',array(
      'name'      => 'reason','label'     => Mage::helper('catalog')->__('Reason'),'title'     => Mage::helper('catalog')->__('Reason'),'style'     => 'width:440px; height:300px;','wysiwyg'   => true,'required'  => false,));
  $fieldset->addField('thumbnail','name' => 'thumbnail',//'values' =>$this->_getAttributeOptions('thumbnail'),//'renderer' => 'Qaz_Qbanner_Block_Adminhtml_Qbanner_Grid_Renderer_Image'
    ));

    if (Mage::getSingleton('adminhtml/session')->getQbannerData()) {
        $form->setValues(Mage::getSingleton('adminhtml/session')->getQbannerData());
        Mage::getSingleton('adminhtml/session')->setQbannerData(null);
    } elseif (Mage::registry('qbanner_data')) {
        $form->setValues(Mage::registry('qbanner_data')->getData());
    }
    return parent::_prepareForm();
}
    protected function _getAttributeOptions($attribute_code)
{
    $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product',$attribute_code);
    $options = array();
    foreach( $attribute->getSource()->getAllOptions(true,true) as $option ) {
        $options[$option['value']] = $option['label'];
    }
    return $options;
}

在这里我的
SaveAction()

public function saveAction() {
             echo print_r( $this->getRequest()->getPost());

     }

我已经捆绑了很好的帖子.有任何想法吗?

解决方法

所有人的常见错误.您只需要在表单中添加表单密钥即可.
只需在表单声明下方添加此行即可.
<input type="hidden" name="form_key" value="<?PHP echo Mage::getSingleton('core/session')->getFormKey(); ?>" />

像这样

<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(); ?>" />

加上这个.现在您可以通过$this-> getRequest() – > getPost()获取参数.

相关文章

操作步骤 1、进入elasticsearch的plugin,进入ik。进入config。 2、在config下面建立以.dic为后缀的字典...
lengend data数据中若存在&#39;&#39;,则表示换行,用&#39;&#39;切割。
代码实现 option = { backgroundColor: &amp;#39;#080b30&amp;#39;, tooltip: { trigger: &...
问题原因 原因在于直接在js中取的变量并复制给var变量。 于是就变成这样。 解决办法 var data = &#...
前言 最近做了一个调查问卷导出的功能,需求是将维护的题目,答案,导出成word,参考了几种方案之后,选...
对于很多人来说,用字符编码都是熟能生巧,而不清楚为什么是那样的字符编码,所以我在这列了一个表,翻...