CakePHP:树列表脚手架

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?

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 with id, name and parent_id columns.

If you want to establish a relationship between models you have to build two models (Section and Parent 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.