Commit 75c9a1a2 authored by Valentin Benozillo's avatar Valentin Benozillo

erp5_web_renderjs_ui: Fix radio field validation

parent e95b12d2
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
} }
rJS(window) rJS(window)
.declareAcquiredMethod("notifyValid", "notifyValid")
.declareAcquiredMethod("notifyInvalid", "notifyInvalid")
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var field_json = options.field_json || {}, var field_json = options.field_json || {},
state_dict = { state_dict = {
...@@ -151,11 +152,20 @@ ...@@ -151,11 +152,20 @@
}, {mutex: 'changestate'}) }, {mutex: 'changestate'})
.declareMethod('checkValidity', function () { .declareMethod('checkValidity', function () {
var name = this.state.name; var name = this.state.name,
gadget = this,
empty;
if (this.state.editable && this.state.required) { if (this.state.editable && this.state.required) {
return this.getContent() return this.getContent()
.push(function (result) { .push(function (result) {
return !result[name]; empty = !result[name];
if (empty) {
return gadget.notifyInvalid("Please fill out this field.");
}
return gadget.notifyValid();
})
.push(function () {
return !empty;
}); });
} }
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment