Email Checkbox Problem

domanb

New Member
Hi there. I'm having a problem with the email function. It emails all the values of my form, except for the checkboxes. I have 6 checkboxes, and if none of them are checked, the email displays the element name, {desired_services}. If one or more are checked off, then it just says Array in the email, but not the actual list of checked items. What's going on here?? I'm using v1.04.

Here's what my email template looks like.
Code:
<b>Name:</b> {first_name_contact} {last_name_contact}<br />
<b>Address:</b> {street}<br />
<b>City:</b> {city}<br />
<b>State/Province:</b> {state}<br />
<b>Country:</b> {country}<br />
<b>Postal Code/ZIP:</b> {postal_code}<br />
<b>Email:</b> {email_address_contact}<br />
<b>Phone:</b> {phone_number}<br />
<b>Desired Services:</b> {desired_services}<br />  <!-- Does not work!!! ??? -->
<b>Desired Meeting Time:</b> {desired_meeting_time}<br />
<b>Desired Meeting Date:</b> {desired_meeting_date}<br />
<b>Message:</b> {message}<br />
</p>
 
This seems like a fairly simple problem. Does nobody know the solution to getting the values of checkboxes into emails?
 
Can't figure this one out as well...
How to trigger the values of the checkboxes in the email form?
 
If I use the generic / default email template the checkboxes also displays "Array" instead of the actual values. So I guess this is a bug in Fabrik
 
hi yes this is a bug, its been fixed in the SVN

If you just want to quickly fix your own version of fabrik without updating to the SVN then edit /components/com_fabrik/fabrik.class.php

Find the lines:

Code:
					switch( $oElement->elementtype_id ){
						case 4:
						case 6:

in the function

Code:
function getTemplateEmail( $data, $fileUploadFound, $tmpl){

and replace with

Code:
					switch( $oElement->elementtype_id ){
						case 4:
						case 6:
						case 3:
 
Hi Rob

And thanks for your reply, however the fix you posted does not seem to help.
I changed the file as you described but I still gets "Array" in the generic/default template.

Are you sure there's nothing more than adding case3 to the function?

EDIT: I tested the code again with a custom email template and THEN it works, but as described it still does not work with the generic/default template.
However this fixes my problem atm, so I'm happy for now.

Thanks and keep up the good work :)
 
ah yes you will need to do the same fix in the "getTextEmail" function:

replace

Code:
switch( $oElement->elementtype_id ){
						case 4:
						case 6:

with

Code:
switch( $oElement->elementtype_id ){
						case 4:
						case 6:
						case 3:
 
Hi again :)

This almost solves the bug, however if not at least 1 subelement is checked when submitting the form, then the email renders {[my element name]} and this is even though I have filled out "Data to record if no checkboxes ticked"
 
Any solutions to this? I have the same issue. It returns the field name if the element is not selected or it returns the label instead of the value set in 'value' if it is selected.
 
I seem to have been able to fix the problem at least for the 1.0.4b version. This assumes you've made the "case 3:" additions as recommended above. Obviously test it before using it yourself. (Rob, if you read this and it isn't right, please let us know...)

In the function getTemplateEmail somewhere around line 1375, change it to the following:

for( $i=0; $i<count( $data[$elName] ); $i++ ){
$tmpData = $data[$elName][$i];
$key = array_search($tmpData, $labels); //changed values to labels
$options .= $values[$key] . "<br />"; //changed labels to values
}

Further down in the same function before the break statement of that same case around 1386 or so, add:

} else { //added this section
if ( is_array( $val ) ) {
$message = str_replace('{' . $elName . '}' , implode("<br />", $val) , $message);
} else {
$message = str_replace('{' . $elName . '}' , $val , $message);
}


This seems to fix the problem with leaving the field name when nothing is selected and also uses the value instead of the label for the value. This same fix likely needs to be added to the getTextEmail function as well but I haven't had time to look at that piece...

I hope this is helpful.
Cheers,
Don
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top