开发者

cakePHP - how to divide managment between controllers and views of different models?

I have two models, lists and lists_items

I have a basic crud structure for them.

I've also set the hasMany(in lists) and belongsTo(in lists_items).

What I want now is to add an option to edit the list_items themselves in the edit view of the parent list.

开发者_如何学C

Please advice me how to create the proper MVC for that.

(I just can't find out what are the correct element/components/etc that I should use 'to do it right', I can simply glue together some MVC pieces and it will work, but I had enough of classic asp)

;-)


I don't think I am answering your questions because there are other problems I see in your setup (at least I assume there is).

Your naming convention: "lists_items" is usually used for a HABTM relationship, and if it's a HABTM you need to put the words in alphabetical order like: "items_lists". If this is a standard belongsTo, you should name the table: "list_items". This is just per convention.

And you should probably use bake to get familiar with the CakePHP file structure and you can study the relationship code in the models.

Being able to edit related "parent" model data is usually not difficult if you are following convention and reading the manual about relationships.


Keep in mind "doing it right" in CakePHP is following the convention that was laid out in the manual. I know NOT every single thing and detail is covered in the manual as a lot of it has to do with general Object Oriented concepts and general programming concepts (understanding arrays etc).. Learning CakePHP effectively is not an overnight process and the only suggestion I can make is practice, practice, practice and read, read, read the manual over and over again :) Best luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜