Forums

empty field->dont show in email

mdma 15 Sep, 2015
Hello, how may this be realised in email-Template custom?

now:
[code<table>
<tr><td>field1</td><td>{field1}</td></tr>
<tr><td>field2</td><td>{field2}</td></tr>[/code]

to something like
<?php echo "<table>"
if (!empty({field1})) { echo <tr><td>field1</td><td>{field1}</td></tr>} 
if (!empty({field2})) {echo<tr><td>field2</td><td>{field2}</td></tr>

?>
mdma 15 Sep, 2015
oh sorry for asking,
I found some similar threads now in the forum
mdma 18 Sep, 2015
Hello, Its getting tougher now
i need a statement like if !empty and !some_value of dropdown show in email


<?php if(!empty($form->data["myfield"]) || !($form->data["myfield"] == some_value)): ?>
myfieldlabel: {myfield}<?php endif; ?>
GreyHead 18 Sep, 2015
Hi mdma,

That should work OK. what exactly is the problem?

Bob

PS I prefer to use a Custom code action before the Email action to process the data and build parts of the template code but either method should work OK.
mdma 18 Sep, 2015
Hello Bob!!
first part is working with !empty field
second part !value of the field doesnt work...
<?php if(!empty($form->data["myfield"]) || !($form->data["myfield"] == some_value)): ?>
myfieldlabel: {myfield}<?php endif; ?>
mdma 18 Sep, 2015
maybe something ith isset?
mdma 18 Sep, 2015
Answer
got it now:

if( !empty($form->data["myfield"]) &&  !($form->data["myfield"] ==some_value)): ?>
myfieldlabel: {myfield}<?php endif; ?>


i use this for a dropdown event:if some_value selected ->show other txt field.
so in the email if "some_value" was selected the data from other txt_field is important
and not the data of dropdown value...
mdma 18 Sep, 2015
and :
<?php if(!empty($form->data["other_txt_field"])): ?>
other_txt_fieldlabel: {other_txt_field}<?php endif; ?>
This topic is locked and no more replies can be posted.