public function afterSave($event) { $model = $this->getOwner(); if ($model->isNewRecord) { foreach ($this->findAllAttaches() as $attach) { $attach->object_id = $model->id; $attach->save(); } } parent::afterSave($event); }
public function afterSave($event) { $attributes = Yii::app()->request->getParam('MetaTag'); if ($attributes) { $meta_tag = MetaTag::model()->findByAttributes(array('object_id' => $this->owner->id, 'model_id' => get_class($this->owner))); if (!$meta_tag) { $meta_tag = new MetaTag(); } $attributes['object_id'] = $this->owner->id; $attributes['model_id'] = get_class($this->owner); $meta_tag->attributes = $attributes; $meta_tag->save(); } return parent::afterSave($event); }