[FIX] web: empty input for empty password field

Revision on https://github.com/odoo/odoo/commit/4b3588feb2b7e260bf237b0f3944c90cdc47c3b5

In order to not replace characters with '*' in edit mode (because of `input`
with type 'password'), the above commit did not format the value at all.
The formatter of a char with the option 'isPassword' turns all of its
characters into '*'. That is not intended for password inputs, because the
content is hidden by the browser with the 'password' type.

The issue with not using the formatter is that an empty field has the value
`false`, so an empty password field produces an non-empty password input with
its value to 'false'.

This commit fixes the issue by forcing empty string for empty password values.

Note: if you use an integer field with password, falsy values (e.g. `0`) become
empty strings in the input value.
This commit is contained in:
Alexandre Kühn
2018-07-27 18:20:02 +02:00
parent 2e440ac662
commit 66dd126053
2 changed files with 29 additions and 1 deletions
@@ -248,7 +248,7 @@ var InputField = DebouncedField.extend({
var inputVal;
if (this.nodeOptions.isPassword) {
inputAttrs = _.extend(inputAttrs, { type: 'password', autocomplete: 'new-password' });
inputVal = this.value;
inputVal = this.value || '';
} else {
inputAttrs = _.extend(inputAttrs, { type: 'text', autocomplete: this.attrs.autocomplete });
inputVal = this._formatValue(this.value);