This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

lucas.sanner54070
lucas.sanner54070

According to the documentation:
If a model already existed in the database and the save method is called, the beforeUpdate / afterUpdate events will fire.
But if I try something like this:

class Foo extends Model {
    public function beforeUpdate()
    {
        // do stuff
    }
}

it turns out that the code within beforeUpdate() is ignored.
What did I do wrong ?

mjauvin
mjauvin

Did you try:

trace_log("beforeUpdate was called");

in your beforeUpdate to see if it gets called?

lucas.sanner54070
lucas.sanner54070

Yes I did. beforeUpdate is not called.

mjauvin
mjauvin

You're right, beforeSave() gets called but not beforeUpdate()...

odd, I'm sure I've used this before. Let me investigate further.

mjauvin
mjauvin

Something is preventing it from being called on SOME of my models and not others... I keep digging.

mjauvin
mjauvin

Ok, so it turns out this will not get called if no changes were made to your model (which makes sense).

So it's working fine.

lucas.sanner54070
lucas.sanner54070

Ok, good to know. Thanks for digging.

1-7 of 7

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.