0

I really getting clueless here:

CActiveForm enableAjaxValidation is set to FALSE.

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'team-form',
        'enableAjaxValidation'=>false,
        'enableClientValidation'=>true,
        'clientOptions'=>array(
            'validateOnSubmit'=>true,

    ),
        'htmlOptions' => array('enctype' => 'multipart/form-data'),
)); ?>

On the controller, I have this line commented:

//$this->performAjaxValidation(array($model,$member));

Still, each time I pass trough the fields, I get the rules messages that setup on the MODEL, so it IS indeed, doing a ajax validation.

Why could this be ?

MEM
  • 30,529
  • 42
  • 121
  • 191
  • 1
    Because you have enableClientValidation set to true? – JorgeeFG Apr 23 '13 at 14:15
  • Still don't get it. If we enable clientSideValidation to true, why does he get's AjaxValidation ? Shouldn't we get Ajax validation only if we set "enableAjaxValidation" true ? – MEM Apr 23 '13 at 14:18
  • I didnt go to the code itself, but I think that when enableClientValidation is set, the jquery plugin for CActiveForm gets initialized with the values. I don't think is doing AJAX, is just javascript validation on client side. To see what is going on, just open your Firebug, go to Console, and go through the fields. You will see there if there is actually any ajax call. – JorgeeFG Apr 23 '13 at 14:34

1 Answers1

1

clientValidation looks nearly the same as ajaxValidation, take a look at your broswer network console and you will see there is no ajax call (except if you submit form since you set validateOnSubmit to true).

EDIT : When you use clientValidation, Yii will add javascript to validate your form attributes depending on the rules you declared in your model. Something like :

jQuery('#model-form').yiiactiveform({
  // ...
    'clientValidation':function(value, messages, attribute) {
       if(jQuery.trim(value)=='') {
         messages.push("Required attribute.");
       }
    },
  // ...
});
soju
  • 25,111
  • 3
  • 68
  • 70
  • if that's the case, how in the world, when we tab inline, from field to field, we get the messages that we wrote on the *model* rules method?? – MEM Apr 23 '13 at 15:15
  • Well, nothing strange, it is what clientValidation do :) – soju Apr 23 '13 at 15:16
  • Arrhgh!!! Please have patience. So clientValidation is going to read the messages on the model? How does it does it ? If it's *client* Validation ? Please note that: if we do change the rules messages, on the MODEL, I do get those messages output when I tab those form fields. – MEM Apr 23 '13 at 15:18
  • despite the fact that THAT as answered my question, and at least I have that figure it out, I still have an issue, that is: I can't get the render partials to work with client side validations, no mater what I try. Any clue? Care to chat. :D:D – MEM Apr 23 '13 at 15:38
  • You should ask another question then :). One hint : try to set `processOutput` to true (last param of `renderPartial`) : http://www.yiiframework.com/doc/api/1.1/CController#renderPartial-detail – soju Apr 23 '13 at 16:43
  • Tried that already. I will ask a new question then. :D (2 min.) – MEM Apr 23 '13 at 16:46
  • Link to the question (with another user): http://stackoverflow.com/questions/16174200/yii-clientside-validation-on-render-partial-not-working – MEM Apr 23 '13 at 16:48