dlthp
dlthp

Reputation: 116

Yii- client side validation is not working on CActiveForm

I've an active form in my application. But the client side validation is not working. The code of the form are as shown below:

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'application-data-student-form',
    'enableAjaxValidation'=>false,
    'enableClientValidation'=>true,
    'clientOptions'=>array('onSubmit'=>true),
    'htmlOptions'=>array(
        'enctype'=>'multipart/form-data',
        'role'=>'form',
        'class'=>'form-horizontal'
    ),
)); ?>

I've used bootstrap 3 in my project. Any idea or solution will be highly appreciated from anybody . . .

Upvotes: 6

Views: 2169

Answers (2)

dlthp
dlthp

Reputation: 116

I've finally resolved the problem. I'm posting this so that it may help someone with the same problem.

The problem was caused because jquery.js was not loaded properly in the application. The map file was missing that is required by the jquery.js. So I downloaded the latest jquery 2.1.1.min.js & respective map file from [http://jquery.com/download/] and loaded them in the main layout. Now the validation is finally working.

Hope this workaround will help someone with same problem.

Upvotes: 3

mosvov
mosvov

Reputation: 57

Try add in model action something like this:

if (Yii::app()->request->isAjaxRequest){
    echo CActiveForm::validate($model);
    Yii::app()->end();
}

or uncoment this line

// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);

Upvotes: 1

Related Questions