magento :如何在后台的form中添加内容可变的select filed
来源:互联网 发布:电脑怎么升级windows 编辑:程序博客网 时间:2024/05/19 12:29
如下图:在product form中添加了一个attribute “spot_spotter”,这个attribute可以选择某个已注册的用户。
注意了,由于这个attribute 的内容是动态变化的,所以这个product attribute 的type是select,但却不能通过常规的方法指定option值。
最后研究出以下的解决方案:
(1)在setup文件中 给attribute添加新的属性 “frontend_input_renderer“, 指定render的block
$eav = new Mage_Eav_Model_Entity_Setup('sales_setup');$eav->updateAttribute('catalog_product', 'spot_spotter', 'frontend_input_renderer', 'spot/adminhtml_catalog_spot_htmlselect');
(2) 然后在mdoule spot中创建 block “Xxx_Spot_Block_Adminhtml_Catalog_Spot_Htmlselect” ,内容如下:
<?phpclass Xxx_Spot_Block_Adminhtml_Catalog_Spot_Htmlselect extends Varien_Data_Form_Element_Select{ public function getValues() { return $this->toCustomerOptionArray(); } public function toCustomerOptionArray(){ $customerSelect=array(); //add empty value $customerSelect[]=array('label'=>"","value"=>"" ); $collection=Mage::getModel('customer/customer')->getCollection() ->addAttributeToSelect("firstname") ->addAttributeToSelect("lastname"); foreach( $collection as $key=>$customer ){ $id=(int)$customer->getId(); $name=$customer->getData("firstname")." ".$customer->getData("lastname"); $customerSelect[]=array('label'=>$name,"value"=>$id); } return $customerSelect; } }
ok。搞定。
- magento :如何在后台的form中添加内容可变的select filed
- DEDECMS:如何在后台左侧菜单显示新建的内容模型
- Magento中后台form中的link类型的使用
- asp.net中, 如何在后台获取访问这个页面的用户的名字?
- 如何在前台的HTML标记中获取后台的变量--转
- 如何在后台配置中找到某个具体配置的事务码
- 如何在后台把本地文件传到服务器的指定目录中
- 如何在后台代码获取控制EditItemTemplate的控件
- JSF如何在后台获得前台页面的标签对象
- 关于mplayer如何在后台播放的问题
- 关于mplayer如何在后台播放的问题
- wpf 如何在后台设置附加属性的值
- WPF 如何在后台进行控件属性的绑定MVVM
- 如何在前台表示层中调用后台代码层中的 datatable 中的内容.....
- 如何在后台线程中将View内容保存成图像
- 【phpcms-v9】phpcms-v9中如何在后台实时管理自己设定的有碎片的页面
- ECMall如何在后台添加模板编…
- .net 如何在后台添加控件,并获取值。
- db2 v9.5 jdbc 批量提交多个insert报错
- VMware tools安装方法(可用)
- WPF 图片灰度处理
- P,B,I三种帧介绍
- cPanel主机自定义php.ini文件
- magento :如何在后台的form中添加内容可变的select filed
- android学习笔记5:屏幕旋转
- js中escape,encodeURI,encodeURIComponent三个函数的区别
- Windows7安装IIS + Windows7安装SQL2005
- 方向比努力重要,努力亦不可少
- 动作识别GestureDetector
- Sizeof与Strlen的区别与联系
- jsp程序设计:jstl之JSTL标签库(上)
- 开始备战。。。。。跑起来。。。。。