dqftyn1717 2014-03-24 07:25
浏览 32
已采纳

将值设置为adminhtml表单模板中的字段

I'd created a template file for admin form tab as:

class Excellence_Designer_Block_Adminhtml_Designer_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {

    protected function _beforeToHtml() {
        $this->addTab('images', array(
            'label' => Mage::helper('designer')->__('Images'),
            'title' => Mage::helper('designer')->__('Images'),
            'content' => $this->getLayout()->createBlock('designer/adminhtml_designer_edit_tab_images')->toHtml(),
        ));

        return parent::_beforeToHtml();
    }

}

class Excellence_Designer_Block_Adminhtml_Designer_Edit_Tab_Images extends
Mage_Adminhtml_Block_Template implements
Mage_Adminhtml_Block_Widget_Tab_Interface {

    public function _construct() {
        parent::_construct();
        $this->setTemplate('designer/edit/tab/images.phtml');
    }

    public function getTabLabel() {
        return $this->__('Images');
    }

    public function getTabTitle() {
        return $this->__('Images');
    }

    public function canShowTab() {
        return true;
    }

    public function isHidden() {
        return false;
    }

}

images.phtml

<div class="input-field">
    <label for="image">Custom Field</label>
    <input type="text" class="input-text" name="image" id="image" />
</div>

but there's no value in there if I do want to edit the form

screen shot even the value is saved in database. The other tab was created with Mage_Adminhtml_Block_Widget_Form and showing the values in fields but for this how could I get the value?

  • 写回答

2条回答 默认 最新

  • duanlie1298 2014-03-24 07:45
    关注

    I'd come to a solution don't know is it the right approach but works in my case. If you have a better solution then let me know.

    I'd made a change in images.phtml

    <div class="input-field">
        <label for="image">Custom Field</label>
        <input type="text" value="<?php echo $this->getValue(); ?>" class="input-text" name="image" id="image" />
    </div>
    

    and added a method in the respective block file

    public function getValue() {
        return Mage::registry('designer_data')->getImage();
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化