I have a hasAndBelongsToMany
relationship set up between my Post
model and Tag
model.
I want a beforeSave()
method in my Tag
model which will execute when tags are saved.
Problem is, in my controller I'm calling $this->Post->save($this->request->data);
and it doesn't seem to fire the beforeSave()
method in the Tag
model, even though they have a relationship between them and tags do get saved along with the post.
I could put my logic in the beforeSave()
method of the Post
model, but then I'd have tag related logic in my Post
model which doesn't seem right.
Is there a way to fire the beforeSave()
method in my Tag
model when a post gets saved?