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. :)
精彩评论