Here is my rules method:
public function rules() {
$newRules = array(
array('password_verification, valid_from, valid_until', 'required'),
array('password_verification', 'length', 'min'=>6, 'max'=>32),
array('password_verification', 'compare', 'compareAttribute'=>'password'),
array('username, email', 'length', 'min'=>3,'max'=>255),
array('password', 'length','min'=>6, 'max'=>32), array('username, email', 'unique'),
array('email', 'email'), array('id, type, username, password, email, valid_from, valid_until', 'safe'),
);
return array_merge($newRules,parent::rules());
}
And here is my view (fields which give a hard time):
<div class="row">
<?php echo $form->labelEx($user,'password_verification',array('label'=>'Verification mot de passe','class'=>'forsys-label')); ?>
<?php echo $form->passwordField($user,'password_verification',array('size'=>30,'maxlength'=>32)); ?>
<?php echo $form->error($user,'password_verification') ?>
</div>
<div class="row">
<?php echo $form->labelEx($user,'valid_from',array('label'=>'Valide depuis le','class'=>'forsys-label')); ?>
<?php echo $form->dateField($user,'valid_from'); ?>
<?php echo $form->error($user,'valid_from'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($user,'valid_until',array('label'=>"Valide jusqu'au",'class'=>'forsys-label')); ?>
<?php echo $form->dateField($user,'valid_until'); ?>
<?php echo $form->error($user,'valid_until'); ?>
</div>
Some informations:
- enableClientValidation and enableAjaxValidation are both at true
- datefield is a costum method. It's not where the problem come from (a colleague use it in the same way I use it without this problem).
My Problem:
For "valid_until" and "valid_from" errors are not displayed on the HTML. If I let "password_verification" empty, when I change the focus an error appears (because of ajaxValidation onChange), but none errors if I let "valid_until" or "valid_from" empty.
But these errors are noticed by Yii, I can see them in firebug if I check the ajax request response.
So if all fields are empty, nothing will be created in DB because of 3 errors, but only one (password_validation) will be displayed.
If any body have an idea, you're welcome :)
Sorry for my approximate english
Thank you for read me, have a good day.
Michaël