Magento在Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract中添加日期列

时间:2016-11-21 16:17:15

标签: php magento

在我的自定义模块中,我成功创建了一个可配置文件:

目前的结果:

enter image description here

我需要4个字段(1个自定义选择字段,OK!)文本字段和2个日期(从 - 到)。

如何添加这些日期列?

我的模块代码如下:

<?php class Vendor_Module_Block_Mymodule_Manager extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract {


protected $_itemRenderer;

public function _prepareToRender(){

    $this->addColumn('seller_id', array(
        'label'    => Mage::helper('adminhtml')->__('Seller'),
        'renderer' => $this->_getRenderer(),
        'style'    => 'width:200px'
    ));

    $this->addColumn('position', array(
        'label' => Mage::helper('adminhtml')->__('Position'),
        'style' => 'width:100px',
    ));

    $this->addColumn('from_date', array(
        'label'     => Mage::helper('adminhtml')->__('From Date'),
        'style'     => 'width:100px',
    ));

    $this->addColumn('to_date', array(
        'label'     => Mage::helper('adminhtml')->__('To Date'),
        'style'     => 'width:100px',
    ));

    $this->_addAfter       = false;
    $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add new rule');

    parent::_construct();
}

protected function  _getRenderer()
{
    if (!$this->_itemRenderer) {
        $this->_itemRenderer = $this->getLayout()->createBlock(
            'vendor_module_block_adminhtml_form_field_seller', '',
            array('is_render_to_js_template' => true)
        );
    }
    return $this->_itemRenderer;
}

protected function _prepareArrayRow(Varien_Object $row)
{
    $row->setData(
        'option_extra_attr_' . $this->_getRenderer()->calcOptionHash($row->getData('seller_id')),
        'selected="selected"'
    );
} }

我试图像这样添加渲染:

    'renderer'  => $this->getLayout()->createBlock(
                                            'mage_core_block_html_date', '',
                                            array('is_render_to_js_template' => true)
                                        )

获得此结果:

使用mage_core_block_html_date渲染器:

enter image description here

0 个答案:

没有答案