Title case (capitalise) field in repeater

Formidable Forms
14 October, 2020 19:21:34
Phil
Topics: 4
Messages: 14
Hi,
I'm using [foreach 13]<tr><td>[15]</td><td>[29]</td></tr>[/foreach] to list values from a repeater in a pdf.
I want the first letter of [15] to be capitalised.
I tried [e2pdf-format-output filter="strtoupper"][15][/e2pdf-format-output] but this broke the repeater arrangement and I ended up with value, value, value.
I tried <span style="text-transform:capitalize;">[15]</span> but no effect.
Please could you advise how I should go about this?
Thanks,
Phil.
15 October, 2020 01:01:06
E2Pdf
Support
Topics: 7
Messages: 3163
Hi,

Unfrotunately yes, [e2pdf-format-output] shortcode wrapper will not working inside repeater section. You can try to wrap needed value with some "span" tag with "class" and add custom filter to your functions.php

For example:
[foreach 13]<tr><td><span class="upper">[15]</span></td><td>[29]</td></tr>[/foreach]

Add function to functions.php: https://codeshare.io/ayBYvz

* Replace inside function:
$e2pdf_template_id to your Template ID
$e2pdf_element_id to your E2Pdf Element ID. It can be found via "Right Mouse Click" -> "Properties" (Element ID) (screenshot attached).

Let us know please if such solution will work for you. Thank you.

We remain at your service.
We would really appreciate your feedback at WordPress.org!
15 October, 2020 01:28:50
Phil
Topics: 4
Messages: 14
Thanks so much for getting back to me so quickly!
I have created the function you wrote and added the <span class="upper"> into the template. But no change.

I don't see where the function defines the class "upper". Is something missing from the above?
Thanks,
Phil.
15 October, 2020 01:41:45
E2Pdf
Support
Topics: 7
Messages: 3163
Did you copied the function to your functions.php with changed $e2pdf_template_id and $e2pdf_element_id ? https://codeshare.io/ayBYvz. This added function must replace data via preg_replace_callback search values with class "upper".

add_filter('e2pdf_extension_render_shortcodes_value', 'e2pdf_extension_render_shortcodes_value_uppercase', 10, 5);
function e2pdf_extension_render_shortcodes_value_uppercase($value, $element_id, $template_id, $item, $dataset) {
$e2pdf_template_id = '11'; //Template ID
$e2pdf_element_id = '1'; //Element ID

if ($template_id == $e2pdf_template_id && $element_id == $e2pdf_element_id && $value) {
$value = preg_replace_callback('/(<span class="upper">)(.*?)(<\/span>)/', function ($matches) {
return ucfirst($matches[2]);
}, $value);
}

return $value;
}
We would really appreciate your feedback at WordPress.org!
15 October, 2020 01:44:03
Phil
Topics: 4
Messages: 14
Thanks.
Yes all copied and set up the template id and element id. The problem seems to come when I add <span "upper"> and </span> into the element. When the e-mail is sent, I just get html at the receipient instead of the formatted e-mail. If I remove those tags, it's ok.
Any further thoughts?
Cheers,
Phil.
15 October, 2020 01:52:26
E2Pdf
Support
Topics: 7
Messages: 3163
<span class="upper"> must not affect actually email functionality, filter must fire only inside generated PDF, however, can you please attach some screenshots of modified "E2Pdf" element value. with <span class="upper"> , screenshot of Element ID and screenshot of inserted function to functions.php? Also screenshot of result of broken email.

P.S. You can mark message "private" so only you and support can see message.

We would really appreciate your feedback at WordPress.org!
15 October, 2020 01:54:24
Phil
Topics: 4
Messages: 14
Sorted!
I think it was the SMTP client I was using. Changed it and OK.
Many thanks for your help.

If I want to use it for another element, do I need to add a new version of the code or can I chain element ids?
15 October, 2020 02:14:22
E2Pdf
Support
Topics: 7
Messages: 3163
Here is an updated function with example of multiple template with multiple elements usage: https://codeshare.io/ayBYlq

There is array which with "key" of E2Pdf Template ID and "sub" array with Element IDs so you can use just 1 function for all needed templates and elements by adding needed values to it.

We remain at your service.
We would really appreciate your feedback at WordPress.org!
15 October, 2020 02:28:47
Phil
Topics: 4
Messages: 14
Thanks - that's brilliant!
Kind regards,
Phil.