Forums

Styling the email that is submitted

WarrenN 04 Mar, 2011
Hi

I have a client that wants their email tidied up by removing any of the {field name} that appear when a check box is not checked. How would I do that?
Also was wondering how I would get the values of any check boxes to each be on their own line when the email is generated instead of separated by commas?
Thanks

Warren
GreyHead 05 Mar, 2011
Hi Warren,

To hide the check box values use this code in the OnSubmit Before box:
<?php
$check0 = JRequest::getVar('check0', '', 'post');
JRequest::setVar('check0', $check0);
?>

This will replace {check0} with a empty string; you could replace '' with 'not checked' or some other value if you prefer.

There is a much more complex example if you search here on 'rucola' (it was for a restaurant).

You can change the array handling by turning off 'Let ChronoForms handle my arrays' and instead using code like this in the OnSubmit Beofer Email box.
<?php
$check1 = JRequest::getVar('check1', array(), 'post', 'array');
$check1 = implode('<br />', $check1);
JRequest::setVar('check1', $check1);
?>

Bob
WarrenN 08 Mar, 2011
Thanks that worked great.
I have a number of checkboxes on the form, could you tell me the correct way to setup a function and call it instead of having the same lines of code?
Currently I am using:
$check2 = JRequest::getVar('check2', '', 'post');
if (!empty($check2)) {
	JRequest::setVar('check2', 'Yes');
}
else{
	JRequest::setVar('check2', $check2);
}

Thanks for your time, I really appreciate it
Warren
GreyHead 08 Mar, 2011
Hi Warren,

Did you check the 'rucola' link?

Bob
WarrenN 08 Mar, 2011
Hi Bob

I did search for it but couldn't find it but have just checked the pizza link(are they one and the same) and will see if I can get something like that working.
Thanks again
Warren
This topic is locked and no more replies can be posted.