Nested Input Settings


(Jared Fisher) #1

Anyone play around with making the input name setting become a nested value in the settings map?

For example:

input “settingName” -> settings.put(“settingName”, “inputValue”)

input “settingName.id1” ends up becoming settings.put(“settingName.id1”, “inputValue”)

but I’d like to achieve settings[“settingName”].put(“id1”, “inputValue”)

So, wondering if there’s a way to work the input’s name argument to achieve that goal. This would make managing dependency settings easier. For cases where the value is a device object (and you can’t add mapped elements to the object), you could just structure your settings like
settings = { “remote”: {“device”: Device Object, “dependent Devices”: [] } }


(Mike Maxwell) #2

Not sure exactly what you’re suggesting, but I’ve had success with this

input(
                name			: "devices"
                ,title			: "whatevs"
                ,multiple		: true
                ,required		: true
                ,type			: "capability.whatevs"
                ,submitOnChange	: true
)
devices.each{ device ->
    input(
                name			: device.id
                ,title			: "something for:" + device.displayName
    )
}

retrieving the value becomes
settings."${device.id}"

or create state maps from the device id
state."${device.id}" = [my big ass data structure here]


(Jared Fisher) #3

Nah, talking about Nesting the setting inside of another map. With your code, you have a setting named devices with a value of the device object. Then you have a setting with the name of the device id and whatever value.

I’m talking about having a setting that resides [“level1”:[“settingname”:deviceObject]]