Attempting to display multiple values of an element separated by a pipe character.

The twig variables available for the 'Custom' multiple items format ({{ value }} and {{ items }}) don't seem to output anything.

How best is it to set a custom separator character?

Comments

alangallery created an issue. See original summary.

alangallery’s picture

StatusFileSize
new1.15 KB

In case its of use to others, for now I've added a pipe option to the functions formatHtmlItems and formatTextItems in WebformElementBase with this patch.

jrockowitz’s picture

Please fix the spacing in the patch and provide test coverage.

jrockowitz’s picture

Status: Active » Needs work
jrockowitz’s picture

Category: Support request » Feature request
cilefen’s picture

Version: 6.2.0-beta5 » 6.2.x-dev
alangallery’s picture

StatusFileSize
new1.18 KB

Not sure why this patch is failing. For me the patch applies okay on 6.2-beta5 and 6.2-dev

cilefen’s picture

Issue tags: +Needs tests

Is that patch made with something besides Git?

Also: you probably don’t need to test every platform combination at this stage.

alangallery’s picture

Thanks cilefen. I just used diff.

The patch test failure message is error: Plugin/WebformElementBase.php: No such file or directory

Comparing a patch generated with Git its very similar to this one but with a/ b/ prefixes indicating the modified files. eg.

--- a/src/Plugin/WebformElementBase.php	2023-03-27 17:30:04.067928500 +0100
+++ b/src/Plugin/WebformElementBase.php	2023-03-27 17:38:59.712840100 +0100

I could amend the patch accordingly and upload again?

jrockowitz’s picture

Version: 6.2.x-dev » 6.1.x-dev
StatusFileSize
new1.76 KB
jrockowitz’s picture

Status: Needs work » Needs review
jrockowitz’s picture

Status: Needs review » Closed (won't fix)
StatusFileSize
new5.33 KB

I just realized you could use custom Twig for pipe delimited values.

See attached the webform and below is the example Twig.

{{ items|join(''|'') }}