PDA

View Full Version : Can't Get Checkbox Group Values in Email


paputxi
10-11-2009, 12:00 PM
I seem to be unable to get checkbox group values via UE. As a test, I created a very simple form using FB, which can be seen at http://southbayenterprise.com/test3/test4.php. Using FB, I defined only two "Lines", where Line 1 is Name (a text field) and Line 2 is a Checkbox Group with three items that I labeled Item 1, Item 2, and Item3. In FB I set the "size" of the Checkbox Group to be One Column so that each item will appear on a separate line on the screen.

Then using UE to setup the email, in the Body tab I setup the four items for the email in the HTML editor part of this tab using DW, as shown in the online tutorial (i.e., binding the form elements to the correct parts of the page that I had just created). The PHP coded listed below is the resulting code generated. (I see this code when I select the Edit button in Body, after setting up the email output via the DW button.)

Name:<?php echo ((isset($_POST["fieldset_group_Name"]))?$_POST["fieldset_group_Name"]:"")?>
CBG Item1:<?php echo ((isset($_POST["fieldset_group_Checkbox_Group[]"]))?$_POST["fieldset_group_Checkbox_Group[]"]:"")?>
CBG Item2:<?php echo ((isset($_POST["fieldset_group_Checkbox_Group[]"]))?$_POST["fieldset_group_Checkbox_Group[]"]:"")?>
CBG Item3:<?php echo ((isset($_POST["fieldset_group_Checkbox_Group[]"]))?$_POST["fieldset_group_Checkbox_Group[]"]:"")?>

However, even though I check one (or more) of the checkboxes when I test it online, they do not show up in the email. I do see that the PHP code for all three Items is identical, which may be part of the problem.

Any thoughts on how to resolve this?

Jason Byrnes
10-13-2009, 11:08 AM
The values of a check box group will be sent as an Array. you can use the PHP implode() function to covert the array to a comma separated list:

<?php echo((isset($_POST["fieldset_group_Checkbox_Group"]))?implode(", ", $_POST["fieldset_group_Checkbox_Group"]):"") ?>

roby258376
12-23-2009, 09:19 AM
This worked great Ray, thanks for the code hint.

But I do have to ask why we have to make this code change after the fact instead of UE working with formbuilder automatically?? I'm sure that many folks use checkbox groups in their forms and would have to search and hopefully find this post in order to get UE to work properly. Is this a fix that's in for the next update?

Ray Borduin
12-23-2009, 09:25 AM
I guess we could make the fix in the bindings so that when you bound to a checkbox group it automatically imploded the array.

It is not on the roadmap, but I will log it as a feature suggestion and we might be able to squeeze it into the next UE update.

roby258376
12-23-2009, 09:54 AM
That would be terrific! thanks

Ray Borduin
12-23-2009, 10:11 AM
I'll make sure it gets added... thanks for the suggestion.