Answer the question
In order to leave comments, you need to log in
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));
}
$this->owner
is defined there, what could be the problem?
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question