当我调用CreateController时,出现此错误:“get_class()期望参数1为对象,数组给定”Yii为两个或更多模型收集数据(Get_Class()期望参数1为对象,数组给定)
控制研究/ actionCreate()如下:
public function actionCreate() {
$model = new Ogrenci;
$model2 =new Adresler;
$this->performAjaxValidation($model, 'ogrenci-form');
$this->performAjaxValidation($model2, 'ogrenci-form');
if (isset($_POST['Ogrenci'],$_POST['Adresler'])) {
$model->setAttributes($_POST['Ogrenci']);
$model2->setAttributes($_POST['Adresler']);
if ($model->save(false) && $model2->save(false)) {
if (Yii::app()->getRequest()->getIsAjaxRequest())
Yii::app()->end();
else
$this->redirect(array('view', 'id' => $model->ogrenci_id));
}
}
$this->render('create', array('model' => $model,'model2' => $model2));
}
create.php:
<?php $this->renderPartial('_form', array(
'model' => array('model'=>$model,'model2'=>$model2),
'buttons' => 'create'));
?>
而且_form.php这个的领域如下:
01上述<div class="row">
<?php echo $form->labelEx($model2,'aciklama'); ?>
<?php echo $form->textField($model2,'aciklama'); ?>
<?php echo $form->error($model2,'aciklama'); ?>
</div><!-- row -->
什么行号,你得到的错误? – acorncom 2013-05-03 18:49:30
/framework/web/helpers/CHtml.php(2220)但它解决了。 谢谢4编辑teresko – Gnosis00 2013-05-04 12:19:05