From: Paul Donald Date: Sat, 31 Jan 2026 22:49:13 +0000 (+0100) Subject: luci-base: do not coerce objects to strings X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=2682aecc7fcf56a09b0489cfa84136286142b8de;p=openwrt-luci.git luci-base: do not coerce objects to strings When getting values from the form, especially in a JSONMap, some objects may be nested, and as such, it's not much use to return '[object Object]'. Return the object instead, so the caller can do something useful with it. This makes multidimensional maps much easier to use. Signed-off-by: Paul Donald --- diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index c6e84e94e4..b5c0ea80a7 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -105,6 +105,9 @@ const CBIJSONConfig = baseclass.extend({ if (Array.isArray(value)) return value; + if (L.isObject(value)) + return value; + if (value != null) return String(value); @@ -122,6 +125,8 @@ const CBIJSONConfig = baseclass.extend({ delete this.data[section][option]; else if (Array.isArray(value)) this.data[section][option] = value; + else if (L.isObject(value)) + this.data[section][option] = value; else this.data[section][option] = String(value); },