0
我是Magento
的新手,我接受了創建擴展的任務。在Magento模塊中發佈表單時出錯?
我正在閱讀文章並繼續前進。
到目前爲止,我可以在管理部分的主導航中添加我的菜單,並在該菜單上調用Controller
並加載我的.phtml
文件的View
。
現在我在我的.phtml
文件上有一個表格,我在同一個控制器上發佈但是在不同的功能上,而不是調用那個功能它要去儀表板。我檢查了表單動作,它很完美,但仍然沒有調用該函數。
以下是我的Controller
的代碼。
class Gwb_Magecrmsync_Adminhtml_CustomersController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout()
->_setActiveMenu('menu1')
->_addBreadcrumb(Mage::helper('adminhtml')->__('Synchronize Data'), Mage::helper('adminhtml')->__('Synchronize Data'))
->_title($this->__('Synchronize Data'));
$block = $this->getLayout()->createBlock(
'Mage_Core_Block_Template',
'my_block_name_here',
array('template' => 'magecrmsync/customers.phtml')
);
$this->getLayout()->getBlock('content')->append($block);
$this->renderLayout();
}
public function authenticationAction()
{
if($this->getRequest()->getPost())
{
try
{
$username = $this->getRequest()->getPost('username');
$password = $this->getRequest()->getPost('password');
// validate user here
}
catch(Exception $e)
{
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
return;
}
}
else
{
echo "NO";
}
//$this->_redirect('*/*/');
}
}
下面是我的customers.phtml
文件代碼:
<form action="<?php echo Mage::getUrl('*/*/authentication'); ?>" method="post">
<fieldset>
<ul>
<li>
<label for="username">Username</label>
<input type="text" id="username" name="username" />
</li>
<li>
<label for="password">Password</label>
<input type="password" id="password" name="password" />
</li>
<li>
<input type="submit" name="authenticate" id="authenticate" value="Authenticate" />
</li>
</ul>
</fieldset>
</form>
請告訴我,我在做什麼錯在這裏。
任何幫助將非常感激,並會對我有幫助。
謝謝
您好安德魯,當我把這個隱藏字段到表單,該值是空白的,它是沒有得到形式鍵。你能告訴我爲什麼嗎? – 2013-03-11 10:03:17
看看這個:http://www.spinonesolutions.com/2011/01/admin-form-post-form_key/ – Andrew 2013-03-11 10:08:19
我剛剛看到,但我不明白爲什麼在我的表格中,鍵是空白的? – 2013-03-11 10:10:08