How to set a custom displayField in CakePHP 3

We can concatenate two fields into a virtual field which will become our new displayField.

In your Entity:

// ...

class YourEntity extends Entity
{
// ...

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

In your Table:

// ...

class YourTable extends Table
{
// ...

public function initialize(array $config)
{
$this->displayField('name_desc');

// ...
}
}

See also:

https://book.cakephp.org/3.0/en/orm/entities.html#creating-virtual-fields