Forums

hide unchecked boxes in email form submission

wdemilly 31 Jan, 2010
I have a form with 21 checkboxes. No checkboxes are required.
When I receive the form submission email it is "messy" to the extent that it shows 21 rows of code, for example
{check}
{check1}
{check2}
{check3}
Checked Item.
{check4}
{check5}
{check6}
{check7}
{check8}
{check9}
Another Checked Item.
{check11}
{check12}
{check13}
{check14}
{check15}
{check16}
{check17}
{check18}
{check19}
{check20}

name, email address
etc. etc.


Is there anything I can do in the email template to send me ONLY results of checked boxes? Thanks!
GreyHead 01 Feb, 2010
Hi wdemilly,

Normally it's easier to work with checkbox arrays rather than loads of individual checkboxes.

Unfortunately unchecked checkboxes don't return anything the in the form results array and ChronoForms isn't clever enough to spot that something is missing. (it's not very clever with checkboxes at all).

I'd probably add some PHP to the beginning of the Email template to check the form results and insert null values for anything that is missing.
<?php
for ( $i = 1, $i <= 20; $i++ ) {
  $temp = JRequest::getVar('check'.$i, '', 'post');
  JRequest::setVar('check'.$i, $temp, 'post');
?>
Not tested and will need debugging.

Yoou may also need to work on the template layout.

Bob

PS To enter PHP into the Email template you must turn the Rich editor off in the Email Setup Properties box.
This topic is locked and no more replies can be posted.