Yii的 - 使用Ajax验证 [英] Yii - Using Ajax Validation

查看:125
本文介绍了Yii的 - 使用Ajax验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想启用一个表格AJAX验证,我已经添加了正确的参数的形式,但它不工作,这是我的code:

I'm trying to enable ajax validation in a form, I've added the right parameters to the form, but it's not working, here's my code:

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'user-form',
    'enableAjaxValidation'=>true,
    'htmlOptions' => array(
            'enctype' => 'multipart/form-data',
            'enableClientValidation'=>true
    ),
)); ?>

请咨询。

推荐答案

在你的行动上,加上下面几行:

In the top of your action, add the following lines:

if(isset($_POST['ajax']) && $_POST['ajax']==='user-form'){
    echo CActiveForm::validate($model);
    Yii::app()->end();
}

这篇关于Yii的 - 使用Ajax验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆