我得到一个错误
Fatal error: Call to a member function hasErrors() on a non-object in F:\xampp\yii\framework\web\helpers\CHtml.php on line 2253
当试图访问URL http://localhost/happybox/index.php/site/cart/3
。 我查看文件cart.php的代码是:
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();
}
?>
我的控制器功能的代码
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));
}
}
可有人请指出错误在此代码,它非常非常重要的,我的。 请帮忙。