E
E
EVOSandru62015-01-27 06:50:10
Yii
EVOSandru6, 2015-01-27 06:50:10

Why is $this->owner not defined in beforeDelete behavior in Yii?

Good afternoon,
I have a behavior where when the model is deleted, in the behavior in beforeSave , many-to-many relationships are also deleted (on the FAQ), it looks something like this:

public function beforeDelete(){
        // echo get_class($this->owner);  // <- Ничего не выводит ??
        $relationship_model = 'L'.ucfirst(get_class($this->getOwner())).'22Faq';
        // Здесь естественно ругается
        $relationship = new $relationship_model();
        $relationship->deleteAllByAttributes(array('CODE_1'=>$this->owner->CODE));
}

There is a setRelations method in the behavior, it $this->owneris defined there, what could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Shcherbin, 2015-02-05
@EVOSandru6

When calling the beforeDelete handler, an object is passed to it - an event (CEvent $event) maybe it will be possible to get the owner from $event->sender?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question