如何在 Magento 的管理员 html 中为控制器创建自定义表单操作?

How to create a custom form action to a controller in admin html from Magento?

我已经在管理中创建了一个表单 html,但是它的动作不能正常工作,动作没有到达控制器。我的 config.xml 文件如下所示

<adminhtml>
        <menu>
            <customercare module="customercare">
                <title>Calls</title>
                <sort_order>100</sort_order>
                <children>
                    <customercare module="customercare">
                        <title>View Missed Calls</title>
                        <sort_order>0</sort_order>
                        <action>admin_customercare/adminhtml_missedcall</action>
                    </customercare>
                    <customercarecalllog module="customercare">
                        <title>View Call Logs</title>
                        <sort_order>1</sort_order>
                        <action>admin_customercare/adminhtml_calllog</action>
                    </customercarecalllog>                    
                </children>
            </customercare>
            <customer>
                    <children>
                            <customercarevirtualretialerrequest module="customercare">
                                    <title>Manage Virtaul Retailers</title>
                                    <sort_order>10</sort_order>
                                    <action>admin_customercare/adminhtml_virtualretialerrequest</action>
                            </customercarevirtualretialerrequest>
                    </children>
            </customer>

        </menu>
        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <customercare translate="title" module="customercare">
                            <title>Calls</title>
                            <sort_order>1000</sort_order>
                            <children>
                                <customercare translate="title">
                                    <title>View Missed Calls</title>
                                </customercare>
                                <customercare translate="title">
                                    <title>Manage Missed Calls</title>
                                    <sort_order>0</sort_order>
                                </customercare>
                                <customercarecalllog translate="title">
                                    <title>View Call Logs</title>
                                    <sort_order>1</sort_order>
                                </customercarecalllog>

                            </children>
                        </customercare>                        
                    </children>
                    <customer>                                        
                            <children>                            
                                <virtualretialerrequest translate="title" module="customer">
                                    <title>Manage Virtual Retailers</title>
                                    <sort_order>10</sort_order>
                                </virtualretialerrequest>                            
                            </children>                                        
                    </customer>

                </admin>
            </resources>
        </acl>

我的控制器文件

<?php
class Suyati_Customercare_Adminhtml_VirtualretialerrequestController extends Mage_Adminhtml_Controller_Action 
{
    protected function _isAllowed()
    {
        return true;
    }

    public function indexAction()
    {

        $this->loadLayout(); 
        $block = $this->getLayout()->createBlock(
            "Mage_Core_Block_Template",
            "virtual-registration",
            array('template' => 'customercare/virtual_retailer_registration_admin_form.phtml')
        );
        $this->_addContent($block);
        $this->renderLayout();

    }

    public function postAction()
    {
        echo "hello"; die();
    }
}

Phtml 表单动作文件位于此路径 app/design/adminhtml/default/default/template/customercare/virtual_retailer_registration_admin_form.phtml

<form action="<?php echo Mage::helper("adminhtml")->getUrl("customercare/virtualretialerrequest/post"); ?>" id="retailerForm" method="post">
    <input type="hidden" name="form_key" value="<? echo $this->getFormKey(); ?>" />

当我尝试提交我的表单时,它将进入仪表板而不是控制器操作文件。请帮我解决这个问题。我只需要获取控制器文件中的 post 数据,并需要向管理员发送电子邮件。

我认为是表单键的问题 改变

<input type="hidden" name="form_key" value="<? echo $this->getFormKey(); ?>" />

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