I couldn't get php working on email action so I had to approach my problem a bit differently. I made custom on submit php code and put for loop there which creates $form->data variable and then tried to insert that to email action template with weird result.
my for loop:
So this creates table rows depending on $counter number. Then I called that $form->data['taulukko'] in my email action like this
But this doesn't really work. It doesnt bring those inputs there as it should. It shows like this in email:
Now it gets weird. If I now put e.g. {nro}{koko}{maara}{savytys} after that {taulukko} then for loop works ok and result is this
If I put these {nro}{koko}{maara}{savytys} BEFORE {taulukko} it doesnt work. So what is going on?
Do I have to put something in that for loop to make it work properly? 🙄
my for loop:
for ($i = 2; $i <= $counter; $i++) {
$form->data['taulukko'] .= '
<tr>
<td style="width: 20px;"><strong>'.$i.'.</strong></td>
<td style="width: 40px;"><strong>Nro:</strong></td>
<td style="width: 50px;">{nro'.$i.'}</td>
<td style="width: 50px;"><strong>Koko:</strong></td>
<td style="width: 60px;">{koko'.$i.'}</td>
<td style="width: 60px;"><strong>Määrä:</strong></td>
<td style="width: 60px;">{maara'.$i.'}</td>
<td style="width: 70px;"><strong>Sävytys:</strong></td>
<td>{savytys'.$i.'}</td>
</tr>
';
}
So this creates table rows depending on $counter number. Then I called that $form->data['taulukko'] in my email action like this
<table>
{taulukko}
</table>
But this doesn't really work. It doesnt bring those inputs there as it should. It shows like this in email:
1. Nro: {nro} Koko: {koko} Määrä: {maara} Sävytys: {savytys}
Now it gets weird. If I now put e.g. {nro}{koko}{maara}{savytys} after that {taulukko} then for loop works ok and result is this
<table>
{taulukko}
</table>
{nro}{koko}{maara}{savytys}
1. Nro: 1234 Koko: 12x15 Määrä: 10 Sävytys: mustavalkoinen
If I put these {nro}{koko}{maara}{savytys} BEFORE {taulukko} it doesnt work. So what is going on?
Do I have to put something in that for loop to make it work properly? 🙄
Hi naggi,
You can't use the curly bracket {input_name} syntax with PHP :-(
Please try
Bob
You can't use the curly bracket {input_name} syntax with PHP :-(
Please try
$form->data['taulukko'] = "";
for ($i = 2; $i <= $counter; $i++) {
$form->data['taulukko'] .= "
<tr>
<td style='width: 20px;'><strong>{$i}</strong></td>
<td style='width: 40px;'><strong>Nro:</strong></td>
<td style='width: 50px;'>{$form->data['nro'.$i]}</td>
<td style='width: 50px;'><strong>Koko:</strong></td>
<td style='width: 60px;'>{$form->data['koko'.$i]}</td>
<td style='width: 60px;'><strong>Määrä:</strong></td>
<td style='width: 60px;'>{$form->data['maara'.$i}</td>
<td style='width: 70px;'><strong>Sävytys:</strong></td>
<td>{$form->data['savytys'.$i]}</td>
</tr>
";
}
Bob
Ah ok. Now its working! Thanks a lot.
So it was only bad coding from my part🙂
Still was pretty weird it worked after inserting those {names} after that {taulukko}
Btw, any idea why I cant put php code in email action template even it says so? Like it matters though since I can put that php custom code before email...
So it was only bad coding from my part🙂
Still was pretty weird it worked after inserting those {names} after that {taulukko}
Btw, any idea why I cant put php code in email action template even it says so? Like it matters though since I can put that php custom code before email...
This topic is locked and no more replies can be posted.