diff --git a/api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts b/api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts index 16fbdb7e37..05fca31e1b 100644 --- a/api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts +++ b/api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts @@ -237,9 +237,10 @@ export const Et2widgetWithSelectMixin = dedupeMixin((superclass) => */ loadFromXML(_node : Element) { - // Read the option-tags - let options = _node.querySelectorAll("option"); let new_options = []; + + // Read the option-tags, but if not rendered there won't be any yet so check existing options + let options = _node.querySelectorAll("option"); for(let i = 0; i < options.length; i++) { new_options.push({ @@ -252,12 +253,19 @@ export const Et2widgetWithSelectMixin = dedupeMixin((superclass) => title: et2_readAttrWithDefault(options[i], "title", "") }); } + if(options.length == 0 && this.__select_options.length) + { + // Start with any existing options, (static options from type) + // Use a copy since we'll probably be modifying it, and we don't want to change for any other + // widget of the same static type + new_options = [...this.__select_options]; + } if(this.id) { new_options = find_select_options(this, {}, new_options); } - if (new_options.length) + if(new_options.length) { this.select_options = new_options; } diff --git a/api/js/etemplate/Et2Select/FindSelectOptions.ts b/api/js/etemplate/Et2Select/FindSelectOptions.ts index 46aada6887..46fc8f7384 100644 --- a/api/js/etemplate/Et2Select/FindSelectOptions.ts +++ b/api/js/etemplate/Et2Select/FindSelectOptions.ts @@ -178,7 +178,10 @@ export function find_select_options(widget, attr_options?, options : SelectOptio } if(!added) { - options.splice(parseInt(i), 0, content_options[i]); + options.splice(parseInt(i), 0, typeof value == "object" ? value : { + value: value, + label: content_options[i] + }); } } content_options = options;