I am trying to include form on product page using renderPartial but it gives error
Fatal error: Call to a member function getErrors() on a non-object in /Applications/MAMP/htdocs/yii/framework/web/helpers/CHtml.php on line 1605
i am using below code…
in product page
// product detail goes here, use below form to make an inquiry about this product
<?php $this->renderPartial('inquiry'); ?>
and in inquiry page page
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'query-form',
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
)); ?>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'name'); ?>
<?php echo $form->textField($model,'name'); ?>
<?php echo $form->error($model,'name'); ?>
</div>
There is a variable called
$modelin your view, but in your controller’srenderPartial()call, you are not passing$modelinto your view. So the view is looking for a variable called$model, but it does not exist.You need to generate a new model in your controller, then pass it into the view, as follows:
The
'model'=>$modeltells Yii to pass the variable$modelinto the view, and the'model'represents the name you use to access that variable from within the view. So if you write something like:Then in the view, you would access the variable by typing
$productinstead of$model.