Hi All
I'm seeing an odd problem with single checkboxes. I have a form that I use to write new records and edit existing. Everything is working fine and I have "Handle Arrays" before the "DB Save" action. What's odd is that I can write a "1" to the db and the value is returned when editing, however it won't write a "0". I believe CF4 had a "ghost" option. Is something like that needed here or should I look to something else...?
Thanks in advance!
-kevin
I'm seeing an odd problem with single checkboxes. I have a form that I use to write new records and edit existing. Everything is working fine and I have "Handle Arrays" before the "DB Save" action. What's odd is that I can write a "1" to the db and the value is returned when editing, however it won't write a "0". I believe CF4 had a "ghost" option. Is something like that needed here or should I look to something else...?
Thanks in advance!
-kevin
Hi Kevin,
If checkboxes aren't checked they don't return anything, not even an empty result. If there isn't a ghost option in CFv5 yet then you have a couple of choices. You could use PHPMyAdmin to set a default value of 0 for those columns. Or, you can add a Custom Code action before the DB Save that looks like this:
Bob
If checkboxes aren't checked they don't return anything, not even an empty result. If there isn't a ghost option in CFv5 yet then you have a couple of choices. You could use PHPMyAdmin to set a default value of 0 for those columns. Or, you can add a Custom Code action before the DB Save that looks like this:
<?php
if ( !isset($form->data['checkbox_name']) ) {
$form->data['checkbox_name'] = 0;
}
?>
Bob
Ah! (lightbulb moment).
That works great. I really like the "open-ness" of CF in how it lets one get in there an manipulate and control many aspects throughout the entire process.
Coffee's on me, Cheers!
That works great. I really like the "open-ness" of CF in how it lets one get in there an manipulate and control many aspects throughout the entire process.
Coffee's on me, Cheers!
This topic is locked and no more replies can be posted.