Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Forcing model::save() to return false

I am wrapping the save() action of a model in an internal, manual transaction. The transaction starts in beforeSave() and commit/rollback is in afterSave().

Even if I rollback the transaction in afterSave(), save() still returns true. Is there any way for me to override this?

do you try any way to fix with model events?

afterSave() can't stop the save operation because it's executed after the save (hence the name). I know save() returns after afterSave() is run - I'm just not sure if I can influence what save() returns.



18.3k
Accepted
answer

I think you have to overwrite save()and use in a common "base" model...

I think you have to overwrite save()and use in a common "base" model...

I don't know why I didn't think of that. Thanks.