开发者

CakePHP: Displayfield in associative model not working

My table Country has a Displayfield Country.

Country is开发者_运维技巧 connected to the Users table through country_id. The displayfield works perfect in the User views.

The User creates Posts and is connected with a foreign key user_id in the Posts table.

Problem: when I use $posts['User']['country_id'], I only can show the country ID itself and not the name. The Displayfield does not work in the associative model Posts.

How can I solve this? Thanks!


You need to set the recursive property to 2. For example:

$this->Post->recursive = 2;
$posts = $this->Post->find('all');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜