我想添加一個新的表單到編輯客戶頁面,到目前爲止很好,使用重寫customer_edit_tabs我能夠添加一個選項卡和我的管理表單到頁面。代碼看起來像這樣。Magento:管理員表單操作不正確
protected function _beforeToHtml()
{
$this->addTab('extraoptions', array(
'label' => Mage::helper('customer')->__('Extra options'),
'class' => 'ajax',
'url' => $this->getUrl('module/adminhtml_tabs/info', array('_current' => true)),
));
這會添加我的選項卡corrently。從那裏選項卡控制器上的鏈接:
public function infoAction()
{
$this->_init();
$this->getResponse()->setBody(
$this->getLayout()->createBlock('module/adminhtml_tabs_edit')->toHtml()
);;
}
此鏈接到我的分塊/ Adminhtml /標籤/ Edit.php
class Namespace_Module_Block_Adminhtml_Tabs_Edit extends Mage_Adminhtml_Block_Widget_Form_Container{public function __construct()
{
parent::__construct();
$this->_objectId = 'id';
$this->_mode = 'edit';
$this->_blockGroup = 'module';
$this->_controller = 'adminhtml_tabs';
$this->_updateButton('save', 'label', Mage::helper('module')->__('Save'));
}
public function getHeaderText()
{
return Mage::helper('module')->__('Extra Options');
}
}
我的座/ Adminhtml /標籤形式容器/Edit/Form.php
class Namespace_Module_Block_Adminhtml_Tabs_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
public function __construct()
{
parent::__construct();
}
protected function _prepareForm()
{
$form = new Varien_Data_Form(array(
'id' => 'info_form',
'action' => $this->getUrl('module/adminhtml_tabs/save', array('id' => $this->getRequest()->getParam('id'))),
'method' => 'post',
'enctype' => 'multipart/form-data'
)
);
$fieldset = $form->addFieldset('extra_options', array('legend' => Mage::helper('module')->__('Extra Options Fieldset')));
$fieldset2->addField('extra', 'text', array(
'name' => 'zip',
'title' => Mage::helper('module')->__('extra'),
'label' => Mage::helper('module')->__('extra data'),
'maxlength' => '250',
'required' => false,
));
$form->setUseContainer(true);
}
protected function _prepareLayout()
{
return parent::_prepareLayout();
}
一切都很好,我有以下默認一個新的按鈕保存客戶的按鈕,但這個保存按鈕不更新動作,所以如果我點擊它,它會轉到默認的客戶/編輯/保存動作,它不告訴我方法不存在它應該。我的猜測是容器出了問題,但我嘗試過三個教程,但沒有什麼區別,希望有人能幫忙,甚至有人會發現我的代碼很有幫助。
是的,我在那裏做了一個動作,但按鈕仍然是從保存客戶的默認。我有兩個保存按鈕應該去默認行動customer_edit /保存,我創建的應該去模塊/ adminhtml_tabs /保存,但我創建一個去customer_edit /保存,所以我不知道什麼即時做錯了確切的,特別是因爲我之前做過這個,我試圖完全複製它,但它沒有奏效。 – changeling 2012-04-04 20:32:26