php - Yii. Object of class AppCompany could not be converted to string on validation -
i've been trying implement ar relations: http://www.yiiframework.com/wiki/19/how-to-use-a-single-form-to-collect-data-for-two-or-more-models/ , doing:
public function actioncreate() { $application = new application; $company = new appcompany; // uncomment following line if ajax validation needed // $this->performajaxvalidation($model); if(isset($_post['application'], $_post['appcompany'])) { $application->attributes=$_post['application']; $company->attributes=$_post['appcompany']; $valid=$application->validate(); $valid=$company->validate() && $valid; if($valid) { if($application->save(false)) { $company->applicant_id = $application->id; $company->save(false); $this->redirect(array('view','id'=>$application->id)); } } } $this->render('create',array( 'application'=>$application, 'company'=>$company, )); } then, when try create new application , enter valid data - data saves both tables. if leave fields empty (while required), have error: object of class appcompany not converted string on validation.
please, kindly figure me on mistake?
Comments
Post a Comment