Add a field formatter for lists

Created on 2 November 2020, over 3 years ago
Updated 18 January 2024, 5 months ago

Problem/Motivation

At the moment there is no export formatter for Lists. Using the existing formatters, we can export either the key or the value, but not both.

In many instances we would want both, for example a list of countries:

AD|Andorra
AE|United Arab Emirates
AF|Afghanistan

Typically a frontend would display "Andorra", but would use "AD" as query string parameter when specifying a sort order, so both are needed.

Lists are a core Drupal field type, so it makes sense that the formatter should be included in rest_views

Proposed resolution

Implement OptionsExportFormatter in rest_views

I would propose a setting which would allow to chose between:

{
  AD: "Andorra"
}

and

{
  key: "AD",
  label: "Andorra"
}

The default formatters can still be used to export just the value of the key, so wouldn't need an extra setting here.

✨ Feature request
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Alice Heaton

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024