示例#1
0
 public function saveInternal()
 {
     $insert = $this->getIsNewRecord();
     if (!$this->beforeSave($insert)) {
         return false;
     }
     if ($this->model->save(false)) {
         foreach ($this->relations as $model) {
             if (!$model->save(false)) {
                 foreach ($model->getErrors() as $attribute => $errors) {
                     foreach ($errors as $error) {
                         $this->addError($attribute, $error);
                     }
                 }
             }
         }
     } else {
         foreach ($this->model->getErrors() as $attribute => $errors) {
             foreach ($errors as $error) {
                 $this->addError($attribute, $error);
             }
         }
     }
     $this->afterSave($insert, $this->attributes());
     return !$this->hasErrors();
 }