Forums

Avoid empty row in email output if the field input is emty

webhand 27 Jan, 2016
Hi

In a form I want to create multiple input-fields. There will be no validation for one field.

It could be, that someone d'ont fill out this input-field. How can I avoid an empty line in this case in the output of the email?

Example of the input-fields:
<input type="text" name="name-1" /> (required field with validation)
<input type="text" name="name-2" /> (not required field without validation)
<input type="text" name="street" /> (required field with validation)
<input type="text" name="city" /> (required field with validation)

Example of the output, if the field "name-2" is emty:
Surname and name
 
Street 12A
12345 City

(Between name and street I will avoid an empty row)

Thanks for any help!

Beat
GreyHead 27 Jan, 2016
Hi Beat,

Edit the Email template and you will find a line like this
<tr><td>Name 2</td><td>{name-2}</td></tr>
Replace it with this version
<?php
if ( !empty($form->data['name-2']) ) {
?>
<tr><td>Name 2</td><td>{name-2}</td></tr>
<?php
}
?>

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