I’m using the form utilities plugin, but I’m struggling with checkbox defaults.
EG
<input name=”company.name” value=”test”>
<input name=”company.id” value=”1”>
<input name=”company.active” type=”checkbox” value=”true”>
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
--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to
coldbox-u...@googlegroups.com
For more options, visit this group at
http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
coldbox+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
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?
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!