开发者

BeforeSave and SaveAll on CakePHP

Ok so I have a relation: Tag HABTM Post. I allow the user to add tags while adding a post, so when he submit the post, the saveAll function saves and creates all the relationships.

Thing is, I found nice and cool logic on nuts-and-bolts-of开发者_开发技巧-cakephp.com which allows me to enter several tags separated with a ',' and also avoids the creation of duplicate tags. And the script basically works on the beforeSave callback.

But this beforeSave logic has to stay on the projects model logic, if I put in the tags model, it doesn't work. So doesn't 'saveAll' calls the beforeSave from the other related models? If not, what would be the best approach? I feel like leaving the tag script in the project model is an option, but not the best one.

tl;dr: I have HABTM relation and when I call saveAll, it doesn't call the related model's beforeSave.

Thanks for any tips. :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜