0
我有一個塊窗體,它只呈現一個Magento的實例。當我在這個特定客戶的不同實例或QA環境中運行相同的代碼時,一切正常。然而,當我進入生產沒有任何呈現在頁面上,_afterToHtml方法沒有被調用。Magento小工具窗體_afterToHtml不叫
正如你在下面的代碼中看到的,我已經用日誌消息強調了正在調用的方法和未調用的方法。容器包裝了一個可以在下面找到的Mage_Adminhtml_Block_Widget_Form。這不是調用_prepareForm(),雖然構造函數被調用。見下面的代碼。
<?php
class My_Module_Block_Adminhtml_Module_Export_Orders
extends Mage_Adminhtml_Block_Widget_Form_Container
{
/**
* Block constructor
*/
public function __construct()
{
$helper = Mage::helper('my_module');
$this->_blockGroup = 'my_module';
$this->_controller = 'adminhtml_module_export';
$this->_mode = 'orders';
$this->_headerText = $helper->__('Export Orders');
$helper->log("This is called");
parent::__construct();
$this->removeButton('reset');
$this->_updateButton('save', 'label', $helper->__('Run Export Job'));
$helper->log("This is called");
}
protected function _prepareLayout()
{
Mage::helper('my_module')->log("This is called");
return parent::_prepareLayout();
}
public function getFormHtml()
{
Mage::helper('my_module')->log("This is NOT called");
return parent::_getFormHtml();
}
protected function _afterToHtml($html)
{
Mage::helper('my_module')->log("This is NOT called");
return $html . '<div>Anything?</div>';
}
protected function _toHtml()
{
Mage::helper('my_module')->log("This is NOT called");
return '<div>Trying this out...</div>';
}
public function getHeaderText()
{
return Mage::helper('my_module')->__('New Export');
}
}
這是Mage_Adminhtml_Block_Widget_Form:
<?php
class My_Module_Block_Adminhtml_Module_Export_Orders_Form
extends Mage_Adminhtml_Block_Widget_Form
{
protected function _construct()
{
Mage::helper('my_module')->log("This is called");
parent::_construct();
Mage::helper('my_module')->log("This is called");
}
protected function _prepareForm()
{
$helper = Mage::helper('my_module');
Mage::helper('my_module')->log("This is NOT called");
$form = new Varien_Data_Form(array(
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save'),
'method' => 'post'
));
$fieldset = $form->addFieldset('export_settings', array(
'legend' => Mage::helper('my_module')->__('Export Configuration')
));
$dateFormat = Varien_Date::DATE_INTERNAL_FORMAT;
$fieldset->addField('from_date', 'date', array(
'name' => 'from_date',
'label' => $helper->__('From Date'),
'title' => $helper->__('From Date'),
'image' => $this->getSkinUrl('images/grid-cal.gif'),
'input_format' => $dateFormat,
'format' => $dateFormat,
'class' => "validate-date"
));
$fieldset->addField('to_date', 'date', array(
'name' => 'to_date',
'label' => $helper->__('To Date'),
'title' => $helper->__('To Date'),
'image' => $this->getSkinUrl('images/grid-cal.gif'),
'input_format' => $dateFormat,
'format' => $dateFormat,
'class' => "validate-date"
));
$storeSwitcher = $fieldset->addField('store_id', 'select', array(
'name' => 'store_id',
'label' => Mage::helper('my_module')->__('Store'),
'title' => Mage::helper('my_module')->__('Store'),
'required' => true,
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)
));
$fieldset->addField('secret_key', 'text', array(
'name' => 'secret_key',
'label' => $helper->__('Secret Key'),
'title' => $helper->__('Secret Key'),
'required' => true
));
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
}
任何人都碰到過類似的問題?請注意,exception.log中沒有任何內容,並且我們的自定義日誌除了在上面的代碼中看到的調試語句之外沒有其他任何異常。