Add some cleanup to find_select_options() make sure we're returning nice arrays instead of objects

This commit is contained in:
nathan 2022-02-03 14:45:14 -07:00
parent 3a1d8dfe11
commit b91f66c629

View File

@ -443,6 +443,17 @@ export function find_select_options(widget, attr_options?, attrs = {}) : SelectO
}
content_options = type_options;
}
// Clean up
if(!Array.isArray(content_options) && typeof content_options === "object" && Object.values(content_options).length > 0)
{
let fixed_options = [];
for(let key in <object>content_options)
{
fixed_options.push({value: key, label: content_options[key]});
}
content_options = fixed_options;
}
return content_options;
}