I’m using the form utilities plugin, but I’m struggling with checkbox defaults.
When that’s submitted, rc.company is a nice struct with the values:
I want a default for company.active, so I added into my submit handler:
rc.company.active = event.getValue(“company.active”,“false”); // ensure there’s a value regardless of whether the checkbox was ticked.
However, the above ALWAYS sets rc.company.active to false – regardless of whether the box was ticked or not.
If I get ride of the event.getValue() line, rc.company.active is true when the box is ticked, and isn’t there when it’s not (expected behaviour).
So how can I set a default value? This seems pretty simple stuff so I’m at a loss as to why it’s not working……
is looking for the string “company.active” in the rc ( rc[“company.active”] ) not rc.company.active.
What I would do is just param the variable.
param name=“rc.company.active” default=“false”;
Hope that helps,
Computer Know How
Shouldn’t the value be in BOTh rc.company.active AND rc[“company.active”]?
Unless the form utils plugin deletes the vars from the rc? Does it?
rc[“company.active”] is a structure with a key of “company.active”.
rc.company.active is a structure with a key of “company”, which is a structure with a key of “active”
In a test file, set and dump them both.
Yep I’m aware of the difference.
I can only presume that the form Utils interceptor copies the values into its automagically created struct, and then deletes the original CB captured rc variables.
I’m paraming them now as suggested by Curt, but I think it would be nice if the form utils interceptor had left the original values there (personally)
There’s a config variable in the forms Util plug called “cleanCollection”, which defaults to true (and removes the original rc fields). Sweet!