本文介绍了如何为多列显示字段使用自定义格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有人知道一种扩展这种方法的正常用法(默认情况下是 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
更多推荐
如何为多列显示字段使用自定义格式?
发布评论