【问题标题】:CakePHP: Displayfield in associative model not workingCakePHP:关联模型中的显示字段不起作用
【发布时间】:2011-07-29 15:57:15
【问题描述】:

我的表 Country 有一个 Displayfield Country。

Country 通过 country_id 连接到 Users 表。显示字段在用户视图中完美运行。

User 创建 Posts 并与 Posts 表中的外键 user_id 连接。

问题:当我使用 $posts['User']['country_id'] 时,我只能显示国家 ID 本身,而不能显示名称。 Displayfield 在关联模型 Posts 中不起作用。

我该如何解决这个问题?谢谢!

【问题讨论】:

    标签: cakephp-1.3


    【解决方案1】:

    需要将递归属性设置为2。例如:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多