CakePHP:树列表脚手架
的以下列
Id | Name | Parent_id
我有一个名为 Sections
的 SQL 表,其中包含我使用 cake Baker
生成的代码
。问题是,如果添加新部分,我无法选择父类别。仅当控制器使用脚手架时它才起作用。
问题是什么?
I have a SQL table called Sections
with the following columns
Id | Name | Parent_id
I had generated the code with cake bake
.
The problem is that if you add a new section, I cannot choose the parent category. It works only when the controller uses scaffolding.
What is the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,如果您想继续,您应该阅读 CakePHP 手册从脚手架。但我尝试为您提供一些线索来帮助您入门。
首先,您必须遵循 CakePHP 约定 并命名表、列、类,属性,...正确的方式。因此,除非您要重写和自定义很多内容,否则您应该以包含
id
、name
和parent_id
的sections
表结尾代码> 列。如果您想在模型之间建立关系,则必须构建两个模型 (<在本例中为 code>Section 和
Parent
)和 配置他们的关系。完成所有这些后,您可以使用
FormHelper
和使用模型的适当方法保存所有内容。First of all you should read the CakePHP manual if you want to move on from scaffolding. But I try to give you a few clues to help you get started.
First of all you have to follow CakePHP conventions and name tables, columns, classes, properties,... the right way. So unless you were overriding and customizing things a lot, you should end with a
sections
table withid
,name
andparent_id
columns.If you want to establish a relationship between models you have to build two models (
Section
andParent
in this case) and configure their relationships.Having all this accomplished you can then build your forms using the
FormHelper
and saving everything using the appropriate methods of your models.