正如在主題中所述,我試圖在自定義模塊的System> Configuration區域中添加一個日期選擇器的日期字段(因此使用etc/system.xml )。添加日期選擇器到自定義模塊上的system.xml
我試圖從下面的線程得到啓示: Magento - Add a button to system.xml with method attached to it
,但沒有成功。
我敢肯定,這是創造合適的塊或方法來創建自定義HTML領域的問題,但我不能讀通Magento的矩陣:)
我停留在上述步驟,我需要的代碼該類(Datefield.php):
<?php
class Namespace_Module_Block_Datefield extends Mage_Adminhtml_Block_System_Config_Form_Field {
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
// ----> Am I wrong in calling ..._Abstract? Should I call Varien_Data_Form_Element_Date? I've tried but no success either...
$this->setElement($element);
$html = // ------------------> what to put here? Call a block or some other method?
->setFormat('d-m-Y')
->setLabel($this->__('Choose date'))
->toHtml();
return $html;
}
}
?>
你有一個技巧,如何做到這一點?
非常感謝。 Hervé
是否有必要在config.xml中註冊此塊? – Ryre 2012-09-19 20:10:27
是的。只要爲模塊使用自定義塊,Block類必須在其config.xml中聲明 – 2012-09-20 10:15:35
感謝您的答覆。我發現有必要在config.xml(Namespace_Module)中註冊「父」,但沒有必要專門註冊日期。 – Ryre 2012-09-20 19:31:26