Mailback & empty fields

  • deonholt
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 27
  • Thank you received: 0

deonholt created the topic: Mailback & empty fields

Hi again.
In our form someone must fill in a maximum of 4 names, but 2 is required. (It is a registration form for our church's golf day.)

What must I do to have BF displays names is there are but show nothing when no names for 3rd and 4th player is entered? (I hope you understand what I mean.)
I make use of custom mails.

Thank you.
Deon
#230071
  • Posts: 2461
  • Karma: 86
  • Thank you received: 333

mihaela replied the topic: Mailback & empty fields

Hello,

When creating a custom email in Advanced options of your form (Admin Emails or Mailback Emails) it often happens that certain fields that are left empty or hidden cause unnecessary empty lines.

To achieve what you want requires some coding and can't be done in the Custom email under Advanced options > More options > Mailback.

Here is an explanation on how to avoid such cases.

To create a custom email template please go to /media/breezingforms/mailtpl/ folder and create there a file named
FORMNAME.html.php for admin emails
or
FORMNAME_mailback.html.php for mailback emails.

You can find out more about templates here crosstec.org/en/support/online-documenta...-templates-work.html


Here is an example of email template for a form that includes textfields “name” and “email” and a multiple-select list named “color”.
<?php

//set variables for every element in your form
$nameTitle = '';
$name = '';

$email = '';
$emailTitle = '';

$color= array(); // for radio group use array
$colorTitle = ''; 

if (count($MAILDATA)){
foreach ($MAILDATA as $data) {
      $title = wordwrap(htmlentities($data[_FF_DATA_TITLE], ENT_QUOTES, 'UTF-8'), 40, '<br />', true);
      $value = nl2br(htmlentities(substr(is_array($data[_FF_DATA_VALUE]) ? implode('|',$data[_FF_DATA_VALUE]) : $data[_FF_DATA_VALUE],0,10000), ENT_QUOTES, 'UTF-8'));
switch($data[_FF_DATA_NAME]){

case 'name':  //replace name with name of another element, LITTERALLY
          $nameTitle = $title;
          $name = $value;
break;  //add a case for every element in your form
case 'email':  
          $emailTitle = $title;
          $email = $value;
break;
case 'color':  
          $colorTitle = $title;
          $color[] = $value;
break;
        }
      }
    }
?>
<?php if ($name!= '') { echo $nameTitle.": ". $name;  ?><br><?php }  ?>
<?php if ($email!= '') { echo $emailTitle.": ". $email;  ?><br><?php }  ?>
<?php if (!empty($color)) { echo $colorTitle.": ". implode(', ', $color);  }  ?>
First, define empty variables for each field of your form that you want to have in the email.
In the IF and FOREACH statement you will take each value from the form and using the SWITCH-CASE statement, each value will be saved in the corresponding variable in the template. Here it is important to put the Names of elements of your form literally into cases.
Finally, if the field isn’t left empty it’s label and value will be part of the email.

Let me know whether you have managed to set this for your form.

Regards,

Mihaela
#230078
  • deonholt
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 27
  • Thank you received: 0

deonholt replied the topic: Mailback & empty fields

Hi again. Thank you very much for a very thorough explanation.

Deon
#230098
  • Posts: 2461
  • Karma: 86
  • Thank you received: 333

mihaela replied the topic: Mailback & empty fields

Hello again,

I'm glad to help you.

Regards,

Mihaela
#230108
Moderators: ForumSupporttomeperica
Time to create page: 0.066 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here