Hide empty fields in email

henkdepoema 04 Jun, 2014
Hello,

In order to only show not empty fields in an 'On Submit-email', I tried to use the solution from this topic (https://www.chronoengine.com/forums/posts/f5/t20430.html?page=1), but it doesn't seem to work.
In the OnSubmit action, I added this Custom Code, just before the Email action:
<?php
 $input_array = array(
   'name' => 'Naam',
   'email' => 'E-mailadres',
   'telefoonnummer' => 'Telefoonnummer',
   'adres' => 'Adres',
   'uitvaart' => 'Soort uitvaart'
 );
 $formulier = array();
 foreach ( $input_array as $k => $v ) {
   $temp = JRequest::getVar($k, '', 'post');
   if ( $temp ) {
     $formulier[] = "$v : $temp";
   }
 }
 JRequest::setVar('formulier', implode('<br />', $formulier));
 ?>

In the Email action I refer to this code with {formulier}, but it shows nothing, except for the other emailtext. What am I doing wrong?
Thanks in advance!

Henk
Max_admin 05 Jun, 2014
Hi Henk,

Please make sure that the editor is disabled in the Email Template box and use this code as an example:

<?php if(!empty($form->data["field_name"])): ?>
{field_name}
<?php endif; ?>


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.