[coldbox 3.5.2] Form Utilities and event.getValue()

I’m using the form utilities plugin, but I’m struggling with checkbox defaults.

EG

When that’s submitted, rc.company is a nice struct with the values:

Handler.cfc:

WriteDump(rc.company);

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.

WriteDump(rc.company)

Simple. Right?

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……

Tom.

This line

event.getValue(“company.active”,“false”);

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,

Curt Gratz

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)

Edit:

There’s a config variable in the forms Util plug called “cleanCollection”, which defaults to true (and removes the original rc fields). Sweet!