Forums

Remove empty field from email Form

ellifrech 21 Mar, 2013
Hello,

I am using 1.5.26 with Chronoforms V3.1RC 5.2

Submit Form fields works. .

However, I'm finding that the email form still shows all empty fields like to remove them. That means: I want to remove an empty field from displaying on the email.
GreyHead 22 Mar, 2013
Hi ellifrech,

Is this just one or two empty fields or do you have many of them?

The version of ChronoForms you are using is now quite old. There are some threads here discussing this if you go far enough back. Basically, you need to pre-process the template code in the Custom Code Before Email box to only include the parts that you need.

Bob
ellifrech 22 Mar, 2013
Hi,

I have more than one or two empty fields.

I fixed all empty fields in the Validatio code Server Side Validation)

<?php
if($_POST['text_3'] =='')
$_POST['text_3'] = 'keine Angabe'; 
if($_POST['text_4'] =='')
$_POST['text_4'] = 'keine Angabe'; 
if($_POST['text_5'] =='')
$_POST['text_5'] = 'keine Angabe'; 
if($_POST['text_6'] =='')
$_POST['text_6'] = 'keine Angabe'; 
if($_POST['text_7'] =='')
$_POST['text_7'] = 'keine Angabe'; 
if($_POST['text_8'] =='')
$_POST['text_8'] = 'keine Angabe'; 
?>

What I really want is to hide fields/their labels in submitted email.

How can I do this?

Sabrina
GreyHead 22 Mar, 2013
Hi Sabrina,

Please post the Email Template HTML as well (or at least the part of it where there variables appear).

Bob
ellifrech 22 Mar, 2013
This is html code of mail template

<p><strong>Vorname</strong>: {text_3}<br />
<strong>Nachname: </strong> {text_1}<br />
<strong>Straße /Hausnr.</strong>: {text_4}<br />
<strong>PLZ / Wohnort</strong>: {text_5}<br />
<strong>Telefonnummer</strong>: {text_6}<br />
<strong>Faxnummer:</strong> {text_7}<br />
<strong>Mobil</strong>: {text_8}</p>
<p><strong>Mailadresse </strong> {text_16}</p>
<p><strong>Nachricht: </strong> {text_9}<br /> <br />
<strong>Kontaktaufnahme erwünscht per</strong> {radio0}<br /> <br /> {file_20}</p>

Is this helpful for You?
GreyHead 31 Mar, 2013
Hi ellifrech,

Then you would need to have something like this in the Email template:
<p>
<?php
$var_array = array(
  'Vorname' => 'text_3',
  'Nachname' => 'text_1',
  'Straße /Hausnr' => 'text_4',
  'PLZ / Wohnort' => 'text_5',
  'Telefonnummer' => 'text_6',
  'Faxnummer' => 'text_7',
  'Mobil' => 'text_8'
);
foreach ( $var_array as $k => $v ) {
  $temp =& JRequest::getVar($v, '', 'post');
  if ( $temp ) {
    echo "<strong>{$k}</strong>: {$temp}<br />";
  }
}
?>
</p>

Bob
ellifrech 31 Mar, 2013
Hi,

many thanks!!!

It runs, but shows me just filled fields on my sreen.

But this is not what I really want.

I do not want to see not filled fields in e-Mail I receive.

Would You please tell me, where I have to make changes in mail.php?


Thank You and Kind Regards

Sabrina
GreyHead 31 Mar, 2013
Hi Sabrina,

Please read my last post again.

Bob
ellifrech 31 Mar, 2013
Now it works 😀

Many, many thanks!!!!!!!!!!!!!!!!!!!!!

Kind Regards

Sabrina
This topic is locked and no more replies can be posted.