# afterSave event not fired on joinTable

**URL:** <https://discourse.cakephp.org/t/aftersave-event-not-fired-on-jointable/7879>\
**Category:** Need Help\
**Created:** [May 28, 2020, 11:35am UTC](https://discourse.cakephp.org/t/aftersave-event-not-fired-on-jointable/7879 "2020-05-28T11:35:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josecanalla](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@Josecanalla](https://discourse.cakephp.org/u/Josecanalla)\
**Post date:** [May 28, 2020, 11:35am UTC](https://discourse.cakephp.org/t/aftersave-event-not-fired-on-jointable/7879/1 "2020-05-28T11:35:38Z")

</div>

I am using CakePHP 3.6.15 with [lifecycle callbacks](https://book.cakephp.org/3/en/orm/table-objects.html#lifecycle-callbacks).

I have Model A and Model B with belongsToMany association using the Model C as joinTable.

When I do a save on model A which modifies content of model C (add data, for example) the afterSave event of model C is never fired. But if I add data directly on model C and then call save on the model, the afterSave event is fired.

Is this the normal behavior? I think yes. So, how can I fire afterSave event on model C when the data of this model is modified, even if the change is done by saving on another model?

---

<div class="post-metadata">

**Author:** ![dreamingmind](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dreamingmind/32/1857_2.png) [@dreamingmind](https://discourse.cakephp.org/u/dreamingmind)\
**Post date:** [May 28, 2020, 7:30pm UTC](https://discourse.cakephp.org/t/aftersave-event-not-fired-on-jointable/7879/2 "2020-05-28T19:30:11Z")

</div>

Possibly this is a case for belongsToMany through?

[https://book.cakephp.org/4/en/orm/associations.html#using-the-through-option](https://book.cakephp.org/4/en/orm/associations.html#using-the-through-option)

Just an untested guess

---

<div class="post-metadata">

**Author:** ![Josecanalla](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@Josecanalla](https://discourse.cakephp.org/u/Josecanalla)\
**Post date:** [May 28, 2020, 7:54pm UTC](https://discourse.cakephp.org/t/aftersave-event-not-fired-on-jointable/7879/3 "2020-05-28T19:54:00Z")

</div>

Yes! I have this option configured but still not works

---

<div class="post-metadata">

**Author:** ![dreamingmind](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dreamingmind/32/1857_2.png) [@dreamingmind](https://discourse.cakephp.org/u/dreamingmind)\
**Post date:** [May 28, 2020, 10:23pm UTC](https://discourse.cakephp.org/t/aftersave-event-not-fired-on-jointable/7879/4 "2020-05-28T22:23:30Z")

</div>

How about using `afterSaveCommit()` [https://book.cakephp.org/4/en/orm/table-objects.html#aftersavecommit](https://book.cakephp.org/4/en/orm/table-objects.html#aftersavecommit)

This could get you the entire saved package instead of the individual entities. Then you could do the steps you need
