E
E
EVOSandru62015-01-23 12:21:42
Yii
EVOSandru6, 2015-01-23 12:21:42

How to make afterSave work in Behaviors in yii?

Good afternoon!
This is the situation.
I have a Service model where there is code like this:

protected function afterSave() {
        echo 'Илья Муромец';
        parent::afterSave();
}

There are 2 behaviors in which I also added afterSave() :
class SomeBehaviour extends CActiveRecordBehavior{
       protected function afterSave() {
                echo 'Добрыня Никитич';
        }
}

and
class AnyBehaviour extends CActiveRecordBehavior{
       protected function afterSave() {
                echo 'Алеша Попович';
        }
}

I attach both behaviors to the class, but for some reason only " Ilya Muromets " comes out of afterSave inside the class. I did the same with beforeSave, all three inscriptions were displayed, what could be the problem?
PS Of course, in a real example, afterSave should perform more interesting tasks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EVOSandru6, 2015-01-23
@EVOSandru6

Understood the error - public must be set in behaviors

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question