Forums

Repeater data email format

zest96 11 Jul, 2024

Hi,I'm trying to send a nice formatted email. The issue is the repeater. 

  1. the data of each repeater isn't stored in a multidimentional array, therefore i need to add a php action to make it. not a big problem.
  2. when sending the email, I want to loop the data into an html table but email action does not execute php.

this is part of my code. in php action, it prints well. moving it to the email action returns a sanitized php code.

$data = $this->data;

$fields = ['chem_name', 'cas_no', 'chem_qty', 'chem_pkg_size', 'chem_clean_rate', 'chem_notes']; // these are my fields in the repeater

$rows = count($data['chem_name']); // this counts the number of repeats cause we don't know

for ($i = 1; $i <= $rows; $i++) {   echo '<tr>';    foreach ($fields as $field) {        echo '<td>' . htmlspecialchars($data[$field][$i]) . '</td>';    echo '</tr>';}

putting this in email body, does not work: <?php echo '<h1>test</h1>';?>

zest96 11 Jul, 2024

Managed to do it:

in PHP action:

ob_start();

// my html formatting

$repeater_list = ob_get_clean();

$this->data['repeater_list'] = $repeater_list;

and in email body:

{data:repeater_list}

now I figure that the repeater data in not saved in the data log :-(

You need to login to be able to post a reply.