Hello…
I have a form that allows to create or update a user.
When the form is in insert mode all works perfect. The problem is when the form is in update mode. The rule says that password field is not required in edit mode and in fact, when the form appears, no asterisk is shown, meaning that YII framework recognize that the field is not required.
When the form is submitted, jformvalidate displays the error telling that password field is required. Is this a bug or there’s something I miss to configure?
This is the whole rule for the model:
public function rules()
{
return array(
array('username, nombres, apellidos, email', 'required'),
array('password, password_repeat', 'required', 'on' => 'insert'),
array('password','length','max'=>50, 'min'=>6, 'on' => 'insert'),
array('password_repeat','length','max'=>50, 'min'=>6, 'on' => 'insert'),
array('password_repeat', 'compare', 'compareAttribute'=>'password', 'on' => 'insert'),
array('username','length','max'=>50),
array('username', 'filter', 'filter'=>'strtolower'),
array('username, nombres, apellidos', 'filter', 'filter'=>'trim'),
array('email','length','max'=>80),
array('email','email'));
}
And this is the part of the form that renders the password fields:
<div class="simple">
<?php echo EHtml::activeLabelEx($model,'password'); ?>
<?php echo EHtml::activePasswordField($model,'password',array('value'=>'', 'size'=>50,'maxlength'=>50)); ?>
</div>
<div class="simple">
<?php echo EHtml::activeLabelEx($model,'password_repeat'); ?>
<?php echo EHtml::activePasswordField($model,'password_repeat',array('size'=>50,'maxlength'=>50)); ?>
</div>
Any help will be greatly appreciated
Thanks
Jaime