How to use a custom format for multi-column display fields?

前端 未结 1 1163
春和景丽
春和景丽 2021-01-13 13:19

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

相关标签:
1条回答
  • 2021-01-13 13:29

    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');
    
            // ...
        }
    }
    

    See also

    • Cookbook > Database Access & ORM > Entites > Creating Virtual Fields
    0 讨论(0)
提交回复
热议问题