Empty field not will sent in the e-mail

entumas 09 Aug, 2016
Hi!

I want that, in case there is an empty field in the form, not to send it in the email. How can I do it?
I know that an empty field will not be sent if it is empty, but its container will be sent. For example:
<table>
    <tr>
        <tr>{field_1}</tr>
    </tr>
    <tr>
        <tr>{field_2}</tr>
    </tr>
</table>

If I only write in in field_1, only appear this field in the email, but also appear the empty space for the structure field_2


I tried to compare with PHP, but it doesn't work. The email has error. I tried this:
<table>
    <?php
    if !({field_1}) {
    <tr>
        <tr>{field_1}</tr>
    </tr>
    }
    ?>
</table>

And this:
<table>
    <?php
    $field_1 = {field_1};
    if !($field_1) {
    <tr>
        <tr>{field_1}</tr>
    </tr>
    }
    ?>
</table>


But it doesn't work

Thanks!
GreyHead 09 Aug, 2016
Answer
1 Likes
Hi entumas,

Your PHP needs fixing :-( Please try
<table>
<?php
if ( !empty($form->data['field_1']) ) {
echo "
    <tr>
        <tr>{$form->data['field_1']}</tr>
    </tr>";
}
?>
</table>

Bob
entumas 09 Aug, 2016
Oh Bob!
As always, your answers provides the solution
Thanks thanks thanks!😀
This topic is locked and no more replies can be posted.