Support string fields with multiple values

Created on 22 June 2023, over 1 year ago
Updated 24 June 2023, over 1 year ago

Problem/Motivation

Thank you for this module that is very close to matching a use case of mine, except that my data is author names in a multiple value text field, and Inotherwords requires the field to be a text list. Attached is a patch that adds a formatter for string fields.

Since processed_text ends up wrapped in <p> tags, I needed to do some twig processing is well. There is probably a better way, but the twig became:

{% apply spaceless %}
  {{ text_before -}}
  {% for item in items %}{{- item|render|striptags|trim(side='right')|replace({',': ', ', 'and': ' and '}) -}}{% endfor %}
  {{- text_after|striptags('<a>')|raw }}
{% endapply %}

This is because after striptags to remove

there was extra spacing around the items, so I had to trim then selectively restore the original spacing (not ideal). The text_after|striptags('<a>')|raw is because I have a hyperlink in my 'after' text.

Remaining tasks

  1. Update implementation so items aren't wrapped in <p> tags.
  2. Test
  3. Profit (in the non-commercial, open-source sense of the word)

User interface changes

Adds In Other Words: List formatter option to string fields.

API changes

None

Data model changes

None

✨ Feature request
Status

Needs work

Version

3.0

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand jonathan_hunt

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024