和原有表单样式保持一致
<?= $form->field($model, 'password_hash')->passwordInput() ?>
<div class="form-group">
<div class="col-sm-2 text-right">
</div>
<div class="col-sm-10">
<label>
<input id="showpassword" type="checkbox"> 显示密码
</label>
</div>
</div>
js部分
<script> // 显示密码 2020-7-9 09:49:07 lmy $('body').on('click','#showpassword',function (res) { if ($('#showpassword').prop('checked')) { $('#member-password_hash').prop('type','text'); }else{ $('#member-password_hash').prop('type','password'); } }) </script>

发表回复