Reputation: 505
I want to set empty this field:
This is my code from _form.php
<div class="row">
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password',array('size'=>50,'maxlength'=>50)); ?>
<?php echo $form->error($model,'password'); ?>
</div>
how to that, please teach me. Thanks all
Upvotes: 1
Views: 2632
Reputation: 18569
This strange behaviour is happen for me too.
I fix it with javascript code to set the password field value to empty.
Yii code:
<div class="row">
<?php echo $form->labelEx($model,'newpassword'); ?>
<?php echo $form->passwordField($model,'newpassword',array('size'=>60,'maxlength'=>128,'value'=>'')); ?>
<?php echo $form->error($model,'newpassword'); ?>
</div>
Javascript code (I am using jQuery) :
<script>
$(document).ready(function()
{
$("#ChangePasswordForm_newpassword").val("");
});
</script>
Upvotes: 0
Reputation: 6606
You can explicitly set the value to be an empty string like this:
<?php echo $form->passwordField($model,'password',array(
'size'=>50,
'maxlength'=>50,
'value'=>'',
)); ?>
Upvotes: 1
Reputation: 3893
Where you are starting your form, you can add htmlOptions like this;
'htmlOptions' => array(
'autocomplete' => 'off'
)
This will disable autocomplete for the whole form. If you just want to do it for a single field, add it to the htmlOptions for that file instead.
Upvotes: 1