Let StringFormatter support UUID field type explicitly

Created on 9 February 2020, almost 5 years ago
Updated 1 July 2024, 6 months ago

Problem/Motivation

While adding a UUID field in a view, no field formatter available, but the input element of selecting formatter is there still. It might make users like me wonder is it something wrong with this field if without a formatter available for it.

By checking code

/**
 * Defines the 'uuid' entity field type.
 *
 * The field uses a newly generated UUID as default value.
 *
 * @FieldType(
 *   id = "uuid",
 *   label = @Translation("UUID"),
 *   description = @Translation("An entity field containing a UUID."),
 *   no_ui = TRUE,
 *   default_formatter = "string"
 * )
 */

Found the string formatter is its default formatter. Further check the string formatter.

/**
 * Plugin implementation of the 'string' formatter.
 *
 * @FieldFormatter(
 *   id = "string",
 *   label = @Translation("Plain text"),
 *   field_types = {
 *     "string",
 *     "uri",
 *   },
 *   quickedit = {
 *     "editor" = "plain_text"
 *   }
 * )
 */

It does not support uuid field type explicitly.

Proposed resolution

There is a uuid_extra contributed module which provides a uuid field formatter. But IMO, it would be better to do it in core by adjusting the annotation of string formatter a little bit, to support uuid field type.

 *   field_types = {
 *     "string",
 *     "uri",
 *   },

to

 *   field_types = {
 *     "string",
 *     "uri",
 *     "uuid",
 *   },
πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
FieldΒ  β†’

Last updated 1 day ago

Created by

πŸ‡¨πŸ‡³China jungle Chongqing, China

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

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.71.5 2024