How to find field through foreign key in cakephp3.

2019-09-11 03:09发布

问题:

how to try like this, i already write in ItemsTable.php like this

public function initialize(array $config) {
        $this->belongsTo('Categories', [
            'className' => 'Item',
            'foreignKey' => 'cid',
            'propertyName' => 'name'
        ]);
}

How do I display category name instead of Cid?