/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); $this->setGroup($this->group); if ($this->scenario == 'update') { // Сохраняем профиль $this->profile->save(false); // Сохраняем данные юридического лица if ($this->profile->legal_person) { if (!$this->person->user_id) { $this->person->user_id = $this->id; } $this->person->save(false); } } }