gpt4 book ai didi

php - CakePHP 不会自动填充 add.ctp 中的父字段

转载 作者:行者123 更新时间:2023-12-02 07:05:45 24 4
gpt4 key购买 nike

我在 this example 之后创建了一个树结构.节点已成功添加,但父字段为空,我无法使用 add.ctp View 将子节点添加到任何节点!如何使用表中已存在的类别名称填充此字段?它不应该自动加载它们吗?正如您在图片中看到的,Parent 字段是空的!

enter image description here

提前感谢您的帮助。

最佳答案

如果您在表单中的字段是 parent_id,您应该在 View 中显示 $parents。因此,您应该在类别中适本地添加操作:

 $parents = $this->Category->Parent->find('list');
$this->set(compact('parents'));

请注意,$this->Category->Parent 仅在您在类别模型中设置了适当的关系时才有效...

关于php - CakePHP 不会自动填充 add.ctp 中的父字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12330515/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com