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');
精彩评论