Commit e70ca940 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Do not crash if no option is selected

parent 486c5025
......@@ -99,15 +99,19 @@
.declareMethod('getContent', function getContent() {
var result = {},
select = this.element.querySelector('select');
select = this.element.querySelector('select'),
selected_option;
if (this.state.editable) {
result[select.getAttribute('name')] =
select.options[select.selectedIndex].value;
// Change the value state in place
// This will prevent the gadget to be changed if
// its parent call render with the same value
// (as ERP5 does in case of formulator error)
this.state.value = result[select.getAttribute('name')];
selected_option = select.options[select.selectedIndex];
if (selected_option !== undefined) {
result[select.getAttribute('name')] =
selected_option.value;
// Change the value state in place
// This will prevent the gadget to be changed if
// its parent call render with the same value
// (as ERP5 does in case of formulator error)
this.state.value = result[select.getAttribute('name')];
}
}
return result;
})
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>977.38881.34981.23125</string> </value>
<value> <string>978.42847.9438.64699</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1569336908.59</float>
<float>1569589427.71</float>
<string>UTC</string>
</tuple>
</state>
......
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