大家好,我正在使用 php 和 Yii 框架创建一个网站。现在我已经创建了一个管理模块并在这个模块中创建了 crud,但似乎我无法创建记录。我现在得到的是:
public function actionCreate()
{
$model=new GamesValidator;
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
/*
if(isset($_POST['ajax']) && $_POST['ajax']==='games-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
*/
if(isset($_POST['GamesForm']))
{
die('GamesForm is set'); // just to see if GamesForm has some value! but website never shows this massege, it shows just new form, which is my problem.
/*
$model->attributes=$_POST['GamesForm'];
if($model->validate()){
echo ('This is only a test');
return;
} else {
echo ('There was some error!');
return;
}
*/
}
$this->render('create',array(
'model'=>$model,
));
}
但它没有显示任何内容,网站再次显示 form.php,就像什么都没做一样。这是我的视图文件中的一些代码:
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'games-form',
'enableAjaxValidation'=>true
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
[..........................]
<div class="row buttons">
<?php echo CHtml::submitButton('Submit'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
抱歉,我无法发布完整的代码,它太长了。
所以你能告诉我有什么问题吗?以及如何检查验证模型是否有错误?
编辑
显示出问题的地方!