File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change 2222 * - currently handles all existing relations, will add support for limitation shortly
2323 * - relations defined with 'through' are not supported yet (http://www.yiiframework.com/doc/guide/1.1/en/database.arr#relational-query-with-through)
2424 *
25- * @todo use AR->hasRelated($name)
26- *
2725 * @property CActiveRecord $owner The owner AR that this behavior is attached to.
2826 *
2927 * @author Carsten Brandt <mail@cebe.cc>
@@ -73,7 +71,7 @@ public function beforeValidate($event)
7371 // attribute of $this->owner has to be changed
7472 case CActiveRecord::BELONGS_TO :
7573
76- if (!$ this ->isRelationSupported ($ relation ))
74+ if (!$ this ->owner -> hasRelated ( $ name ) || ! $ this -> isRelationSupported ($ relation ))
7775 break ;
7876
7977 $ pk =null ;
@@ -130,7 +128,7 @@ public function afterSave($event)
130128 */
131129 case CActiveRecord::MANY_MANY :
132130
133- if (!$ this ->isRelationSupported ($ relation ))
131+ if (!$ this ->owner -> hasRelated ( $ name ) || ! $ this -> isRelationSupported ($ relation ))
134132 break ;
135133
136134 Yii::trace ('updating MANY_MANY table for relation ' .get_class ($ this ->owner ).'. ' .$ name ,'system.db.ar.CActiveRecord ' );
@@ -174,7 +172,7 @@ public function afterSave($event)
174172 case CActiveRecord::HAS_MANY :
175173 case CActiveRecord::HAS_ONE :
176174
177- if (!$ this ->isRelationSupported ($ relation ))
175+ if (!$ this ->owner -> hasRelated ( $ name ) || ! $ this -> isRelationSupported ($ relation ))
178176 break ;
179177
180178 Yii::trace (
You can’t perform that action at this time.
0 commit comments