I have made up a custom template like this example below:
for example, as address is not required, if someone leaves blank one of the two (address or number) the template returns a strange output:
Full Name Example Name
Email examplemail@mail.com
Address ,4
or
Full Name Example Name
Email examplemail@mail.com
Address Avenue Street,
in each case the comma is always there, pesky and meddlesome. Is there any way to avoid such a thing?
p><b>To: {recipient_name}</b><br>
A message was sent to you from website:<br>
<b><i>www.example.com</i></b>:</p>
<table>
<tr><td>Full Name</td><td><i>{fullname}</i></td></tr>
<tr><td>Email</td><td><i>{email}</i></td></tr>
<tr><td>Address</td><td><i>{address}, {number}</i></td></tr>
</table>
for example, as address is not required, if someone leaves blank one of the two (address or number) the template returns a strange output:
Full Name Example Name
Email examplemail@mail.com
Address ,4
or
Full Name Example Name
Email examplemail@mail.com
Address Avenue Street,
in each case the comma is always there, pesky and meddlesome. Is there any way to avoid such a thing?
I suspect that the solution might be similiar with this with use of a custome code. But I don't know how to achieve this.
Hi jdran,
Please try this in a Custom Code action
Bob
Please try this in a Custom Code action
<?php
if ( empty($form->data['address']) && empty($form->data['number']) ) {
$form->data['address_number'] = '';
} else if ( empty($form->data['address']) ) {
$form->data['address_number'] = $form->data['number'];
} else if ( empty($form->data['number']) ) {
$form->data['address_number'] = $form->data['address'];
} else {
$form->data['address_number'] = $form->data['address'].', '.$form->data['number'];
}
?>
Then put {address_number} in the email template.
Bob
This topic is locked and no more replies can be posted.