Skipping empty fields in form mail

Ask your feature Requests about CKforms component

Skipping empty fields in form mail

Postby medial » Fri Mar 12, 2010 2:28 pm

I have made a long form with many checkboxes.
When an form gets filled in and submitted, a mail is sent to me.
I would like to see an option where fields that are left open, are skipped when sending mail.

ie: when a form with 100 checkboxes, only 2 boxes are selected, I want the mail to contain only the names of the checkboxes marked.

The same option with other field-types as well

TiA,
medial
medial
 
Posts: 3
Joined: Fri Mar 12, 2010 2:05 pm
Top

Re: Skipping empty fields in form mail

Postby webmeusel » Tue Apr 20, 2010 1:48 pm

Hi,
I have the same problem! This option makes thing mutch more easier! Please work on it!!!

Thanks in Advance
webmeusel
 
Posts: 2
Joined: Tue Apr 20, 2010 1:45 pm
Top

Re: Skipping empty fields in form mail

Postby clwheatley » Tue Apr 20, 2010 7:41 pm

I've had this problem ever since I started using CKForms 1.2.0. The solution I found is fairly simple and requires editing of /components/com_ckforms/models/ckforms.php. Note, you should back up the original before making any changes just to be safe.

This file has changed with practically each new revision since 1.2.0, but for version 1.3.4_b2 change line 457 from:
Code: Select all
$mailBody = $mailBody.$field->label . " : " . $fieldValue . "<br />\n";

To:
Code: Select all
               if ($fieldValue != "") {
                  if (!is_null($field->label)) {
                     $mailBody = $mailBody.$field->label . " : " . $fieldValue . "<br />\n";
                  }
                  else {
                     $mailBody = $mailBody.$field->name . " : " . $fieldValue . "<br />\n";
                  }
               }

This removes empty fields (such as horizontal rule lines) from the message you receive and additionally, should a field label be blank for any reason, replaces the blank field label to the field name.

You'll also want to change line 561 or 569 (depending if you've already made the previous change). This will apply the fix to email receipts users would receive.

Blessings,

Chris
clwheatley
 
Posts: 3
Joined: Tue Apr 20, 2010 7:30 pm
Top

Re: Skipping empty fields in form mail

Postby webmeusel » Tue Apr 20, 2010 10:51 pm

Hi Chris,

that is exactly what I was looking for! Many Thanks!!! The only changing what I made additional was that I change the
Code: Select all
($fieldValue != "")
field check to
Code: Select all
($fieldValue != "0")
in my form I have a lot of 0 value as default when there is no entry!
:DI am realy happy :D
webmeusel
 
Posts: 2
Joined: Tue Apr 20, 2010 1:45 pm
Top

Re: Skipping empty fields in form mail

Postby clwheatley » Thu Apr 22, 2010 8:20 pm

I am glad that helps.

If you want to have it check for both empty values or values equal to zero, as in your case you can change it to:
Code: Select all
if ($fieldValue != "0" && $fieldValue != "") {


This way you won't receive either a zero or a blank value.

Chris
clwheatley
 
Posts: 3
Joined: Tue Apr 20, 2010 7:30 pm
Top


Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 1 guest

cron