Forums

Chronoforms to Email with Checkbox

lydianp18 08 Mar, 2016
I have a form with about 60 checkbox pairs (different arrays), ideally they need to be output as checkboxes, not "yes" and "no". I found something similar in this post: http://www.chronoengine.com/forums/posts/f5/t94438/chronoforms-to-pdf-with-checkmark.html?hilit=checkbox

<?php if($_POST['sic_aziendale'] == "1") {
echo "<img src=\"/image/square.jpg\" />";
}else{
echo "Ffff";
}?>


1) I'm not sure if this would do it for ALL the checkboxes, or it's setup just for one specific field (ideally I'd like ALL checkboxes to display as actually checkboxes in the email, and prefer not to have to write code for them individually for all 60...)

2) I'm not sure where I would put it in the actions.

Thanks
Lydia
GreyHead 09 Mar, 2016
Hi Lydia,

What are the names and values of your checkbox groups? If you add a Debugger action to the form On Submit event, then check all the boxes and Submit the form you should see all this info in the Debugger output.

Are you sure that you want to use images in emails - some email readers will not download them by default? It might be better to use the UTF characters instead. See this StackOverFlow answer for an example.

Bob
lydianp18 09 Mar, 2016
Bob,

Thanks. I haven't tried setting it up yet, was trying to figure out how. This helps a lot thanks.

Lydia
lydianp18 09 Mar, 2016
Ok - I've tried this and it doesn't work (It's still outputing "Yes" or "No". I've attached my flow in setup.

This is the code in custom code (seriousill is the field ID (fieldname is seriousill[] ) of one of the yes/no checkbox form fields. The values are Yes | No):

<?php if($_POST['seriousill'] == "Yes") {
    echo " ☒";
    }else{
    echo "☐";
    }?>


Thanks,
L
GreyHead 09 Mar, 2016
Hi Lydia,

If you echo it from the Custom Code it will just be shown in the Thank You page somewhere. Please try this
<?php
if ( $form->data['seriousill'] == 'Yes' ) {
  $form->data['seriousill_chk'] = ' ☒';
} else {
  $form->data['seriousill_chk'] = ' ☐';
}
?>
Then put {seriousill_chk} in the Email template.

Bob
lydianp18 10 Mar, 2016
Answer
Worked like a charm - thanks!

Note, in case anyone else needs it: Had to switch to image files to get it to work on the pdf, so running 2 separate if/elses in custom code for each one, ie:
For email:
  if ( $form->data['seriousill'] == 'Yes' ) {
      $form->data['seriousill_chk'] = '☒ Yes ☐ No';
    } else {
      $form->data['seriousill_chk'] = '☐ Yes ☒ No';
    }

For pdf:
 if ( $form->data['seriousill'] == 'Yes' ) {
      $form->data['seriousill_pdf'] = '<img src="http://www.remarkablesmiles.com/yes.jpg" />';
    } else {
      $form->data['seriousill_pdf'] = '<img src="http://www.remarkablesmiles.com/no.jpg" />';
    }


In both cases results look like this:
or
GreyHead 11 Mar, 2016
Hi Lydia,

It doesn't work with the characters in the PDF because the fonts used there probably don't include those characters. You can add extra fonts with fuller character sets if necessary. I think that we did that a couple of times before.

Bob
This topic is locked and no more replies can be posted.