[IMP] web: add decoration support for all field widgets (#25160)
It is sometimes useful to be able to customize slightly the color of a field depending on some conditions on the current record. For example, imagine that we want to show a VAT number field in green/red, if it was validated or not. To do that, we can add a field with an onchange, and simply add decoration-danger and decoration-success attributes to the field.
This commit is contained in:
@@ -206,6 +206,13 @@ var InputField = DebouncedField.extend({
|
||||
this.isDirty = false;
|
||||
}
|
||||
if (this.isDirty || (event && event.target === this && event.data.changes[this.name] === this.value)) {
|
||||
if (this.attrs.decorations) {
|
||||
// if a field is modified, then it could have triggered an onchange
|
||||
// which changed some of its decorations. Since we bypass the
|
||||
// render function, we need to apply decorations here to make
|
||||
// sure they are recomputed.
|
||||
this._applyDecorations();
|
||||
}
|
||||
return $.when();
|
||||
} else {
|
||||
return this._render();
|
||||
|
||||
Reference in New Issue
Block a user