Remove empty rows

Forminator Forms Released
February 19, 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>
February 20, 2023 03:57:50
E2Pdf
Topics: 7
Messages: 3617
Support
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!
February 23, 2023 01:27:20
E2Pdf
Topics: 7
Messages: 3617
Support
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!
February 26, 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
Get News and Updates
Our monthly newsletter keeps you in the loop, so you'll always be up to date with the latest news and updates about E2Pdf.
* You can update your email subscription preferences here.
All trademarks, service marks, trade names, product names, and logos appearing on this website are the property of their respective owners. The use of trademarks such as Formidable Forms®, Forminator Forms®, Gravity Forms®, JetFormBuilder®, WordPress®, WooCommerce®, WPForms® and others is solely for identification purposes (nominative use) and does not imply any affiliation, sponsorship, or endorsement by the respective trademark holders.
© 2017 - 2026, https://e2pdf.com

We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements. By clicking "Accept Selected", you consent to use of selected cookies according to our Cookie Policy.