I am getting an errorFatal error: Call to a member function hasErrors() on a non-object in F:\xampp\yii\framework\web\helpers\CHtml.php on line 2253
when trying to access the url http://localhost/happybox/index.php/site/cart/3
. The code of my view file cart.php is:
Hello, <?php echo ucwords(Yii::app()->user->name); ?>,<br/>
This is your cart<br/>
Click on Order to Place and Order.<br/>
<?php
$Orders = Orders::model()->findAll(array(
'select'=>'products_id',
'condition'=>'users_id=:id && type=:type',
'params'=>array(':id'=>Yii::app()->user->id, ':type'=>'cart'),
));
?>
<?php
if($Orders){
foreach ($Orders as $order) {
echo '<br/>'.$order->products->title.'<br/>'.$order->products->description.'<br/>';
}
}else{
echo 'Your Cart is Empty';
}
?><br/><br/>
<?php
if($Orders){
$form=$this->beginWidget('CActiveForm', array('id'=>'order-form'));
echo $form->hiddenField($model,'users_id',array('value'=>Yii::app()->user->id));
echo CHtml::submitButton('Confirm Your Order');
$this->endWidget();
}
?>
The code of my controller function is
public function actionCart($id){
if(Yii::app()->user->isGuest){
$this->redirect('login');
}else{
$model=$this->loadModel($id);
if(isset($_POST['Orders']))
{
//do something
}
$this->render('cart', array('model'=>$model));
}
}
Can someone please point out the error in this code, Its very very important for me. Please help.