diff --git a/CHANGELOG b/CHANGELOG
index f8dfcb3371..8623edc577 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+* Allow to show plain text in password field
+
Version 4.2.0 - 2016-11-28
* Bug fixes (see mercurial logs for details)
* Add PYSON Widget
diff --git a/src/view/form.js b/src/view/form.js
index 9f607754f5..614632d014 100644
--- a/src/view/form.js
+++ b/src/view/form.js
@@ -1276,6 +1276,32 @@ function eval_pyson(value){
Sao.View.Form.Password._super.init.call(this, field_name, model,
attributes);
this.input.prop('type', 'password');
+ this.button = jQuery('', {
+ 'class': 'btn btn-default btn-sm form-control',
+ 'type': 'button'
+ }).appendTo(jQuery('', {
+ 'class': 'input-group-btn'
+ }).appendTo(this.group));
+ this._set_password_label();
+ this.button.click(this.toggle_visibility.bind(this));
+
+ },
+ toggle_visibility: function() {
+ if (this.input.prop('type') == 'password') {
+ this.input.prop('type', 'text');
+ this.input.attr('autocomplete', 'off');
+ } else {
+ this.input.prop('type', 'password');
+ this.input.removeAttr('autocomplete');
+ }
+ this._set_password_label();
+ },
+ _set_password_label: function() {
+ if (this.input.prop('type') == 'password') {
+ this.button.text(Sao.i18n.gettext('Show'));
+ } else {
+ this.button.text(Sao.i18n.gettext('Hide'));
+ }
}
});