Problem/Motivation

Is it possible to have a new line feed as a Concatenated values separator?

I have tried both \n and
and the value gets printed as is, even when checking the appropriate settings for not stripping html, converting new lines to
, etc.

Perhaps I'm doing something wrong, thanks in advanced for any help.

Comments

apparatchik created an issue. See original summary.

davidwhthomas’s picture

Status: Active » Closed (works as designed)

Only literal strings are supported for the separator value.

The separator value is passed directly into the SQL query and to keep the query safe with user input it is wrapped in Drupal's database connection quote() function - for proper SQL escaping. This means the separator is treated as a literal string.

I'm open to reconsidering this if there's a simple way to handle it safely, but given the separator value is user supplied, we need to be careful to ensure it's properly sanitized.

However further formatting can be applied at the theme layer. A workaround for your case is to apply a newline transformation after the query. For example by processing the field output to replace a placeholder separator (e.g. ||) with a
or newline, in a preprocess function or template.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

apparatchik’s picture

Thank you for your response, the need specifically is to have large listings with poor readability such as:

large string A, large string B, ... large string Z

Be displayed like:

large string A
large string B
...
large string Z

I guess we could have a checkbox that automatically adds a CHAR(10) or line break to the separator in the SQL query, but this might be too specific for my individual use case. I ended up implementing a workaround similar to what you mentioned.