如何为多列显示字段使用自定义格式?

编程入门 行业动态 更新时间:2024-10-22 23:34:29
本文介绍了如何为多列显示字段使用自定义格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有人知道一种扩展这种方法的正常用法(默认情况下是 id ,并且容易改为 field1 )?我有一个displayField集合如下:

Is anyone aware of a way of expanding the 'normal' uses of this (it's id by default and easily changed to field1)? I have one displayField sets follows:

$this->displayField(['name', 'desc']);

显示为描述在模板文件中调用时。我知道这是一个fudge,但它有一种方式,我可以操纵这个显示名称 - 描述例如,只需使用 displayField ?

Which displays as Name; Description when called in a template file. I know it's a fudge, but it there a way I can manipulate this to have it display Name - Description for example, just by using the displayField?

推荐答案

使用虚拟字段,并指定用作显示字段列,

Use a virtual field, and specify that to be used as display field instead of using multiple columns, something along the lines of

// ... class YourEntity extends Entity { // ... protected function _getNameDesc() { return $this->_properties['name'] . ' - ' . $this->_properties['desc']; } }

// ... class YourTable extends Table { // ... public function initialize(array $config) { $this->displayField('name_desc'); // ... } }

另请参阅

  • Cookbook>数据库访问& ORM> Entites> Creating Virtual Fields

更多推荐

如何为多列显示字段使用自定义格式?

本文发布于:2023-10-28 19:33:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1537580.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   字段   何为   格式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!