Remove empty rows

Forminator Forms Released
19 February, 2023 18:58:06
mylarbi
Topics: 3
Messages: 6
Hi, my form gives users the option to enter up to 9 item names and their prices.
I have used a table html to show them on the pdf.
I have tried to construct a preg_replace to remove empty rows following examples in this forum.
However, I have not succeeded. Kindly help.

The html code is
<table><tbody><tr><th style="text-align: center; height: 20px; width: 10%;"><u>No.</u></th><th style="width: 70%"><u>Item</u></th><th style="text-align: right; width=20%"><u>Amount</u></th></tr><tr><td style="text-align: center;">1.</td><td>{text-2:1}</td><td style="text-align: right;">{currency-1:1}</td></tr><tr><td style="text-align: center;">2.</td><td>{text-2:2}</td><td style="text-align: right;">{currency-1:2}</td></tr><tr><td style="text-align: center;">3.</td><td>{text-2:3}</td><td style="text-align: right;">{currency-1:3}</td></tr><tr><td style="text-align: center;">4.</td><td>{text-2:4}</td><td style="text-align: right;">{currency-1:4}</td></tr><tr><td style="text-align: center;">5.</td><td>{text-2:5}</td><td style="text-align: right;">{currency-1:5}</td></tr><tr><td style="text-align: center;">6.</td><td>{text-2:6}</td><td style="text-align: right;">{currency-1:6}</td></tr><tr><td style="text-align: center;">7.</td><td>{text-2:7}</td><td style="text-align: right;">{currency-1:7}</td></tr><tr><td style="text-align: center;">8.</td><td>{text-2:8}</td><td style="text-align: right;">{currency-1:8}</td></tr><tr><td style="text-align: center;">9.</td><td>{text-2:9}</td><td style="text-align: right;">{currency-1:9}</td></tr><tr><td></td><td><b>TOTAL</b></td><td style="text-align: right;"><b>{calculation-1} GBP</b></td></tr></tbody></table>
20 February, 2023 03:57:50
E2Pdf
Support
Topics: 7
Messages: 3330
Hi,

Try to use "Preg Replace Pattern" as:

/<tr><td[^>]+>(\d)\.<\/td><td>\{(.*?)\}<\/td><td[^>]+>\{(.*?)\}<\/td><\/tr>/

P.S. We also marked the topic as "Feature request", to add the possibility generate an "index" via "foreach" shortcode.

We remain at your service.
We would really appreciate your feedback at WordPress.org!
23 February, 2023 01:27:20
E2Pdf
Support
Topics: 7
Messages: 3330
Hi,

We currently released an update that allows using {foreach-index} inside {foreach} loop, so you must be able to use the constructions as:

<table>
<tbody>
<tr><th style="text-align: center; height: 20px; width: 10%;"><u>No.</u></th><th style="width: 70%"><u>Item</u></th><th style="text-align: right; width=20%"><u>Amount</u></th></tr>
{foreach:group-1}
<tr><td style="text-align: center;">{foreach-index}.</td><td>{text-2}</td><td style="text-align: right;">{currency-1}</td></tr>
{/foreach:group-1}
<tr><td></td><td><b>TOTAL</b></td><td style="text-align: right;"><b>{calculation-1} GBP</b></td></tr>
</tbody>
</table>

P.S. Keep in mind please that "Disable WYSIWYG Editor" must be checked.
We would really appreciate your feedback at WordPress.org!
26 February, 2023 06:56:43
mylarbi
Topics: 3
Messages: 6
The new feature works perfectly and I no longer have to use regex whose complexity I still don't understand. Thanks