From: Jo-Philipp Wich Date: Sun, 14 Jun 2020 14:41:02 +0000 (+0200) Subject: luci-base: form.js: fix handling of array sections in JSONMap forms X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b894a3b9aae829e51ce8f6dce50f7741fc0dc075;p=oweals%2Fluci.git luci-base: form.js: fix handling of array sections in JSONMap forms Signed-off-by: Jo-Philipp Wich (cherry picked from commit 682f628ea611d8d12a2a4b5925851f99c5a4bd20) --- diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index c1331fb34..b92ef235a 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -19,17 +19,7 @@ var CBIJSONConfig = baseclass.extend({ if (!data.hasOwnProperty(sectiontype)) continue; - if (L.isObject(data[sectiontype])) { - this.data[sectiontype] = Object.assign(data[sectiontype], { - '.anonymous': false, - '.name': sectiontype, - '.type': sectiontype - }); - - section_ids.push(sectiontype); - num_sections++; - } - else if (Array.isArray(data[sectiontype])) { + if (Array.isArray(data[sectiontype])) { for (var i = 0, index = 0; i < data[sectiontype].length; i++) { var item = data[sectiontype][i], anonymous, name; @@ -57,6 +47,16 @@ var CBIJSONConfig = baseclass.extend({ }); } } + else if (L.isObject(data[sectiontype])) { + this.data[sectiontype] = Object.assign(data[sectiontype], { + '.anonymous': false, + '.name': sectiontype, + '.type': sectiontype + }); + + section_ids.push(sectiontype); + num_sections++; + } } section_ids.sort(L.bind(function(a, b) {