Skip to content

MakeReadOnly with comma in format string causes invalid "This field exceeds the allowed amount of items" error #193

@leahtheusch

Description

@leahtheusch

Describe the bug
When using MakeReadOnly on an editor field and expecting a max value of one item, if the provided format function returns a string containing a comma (,), the Entity Picker UI misbehaves. Specifically, the picker treats the formatted string as if it contains multiple values. This results in the validation error: This field exceeds the allowed amount of items even though only a single entity is selected.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Configure a field with .MakeReadOnly(context => context.EditorMode == EditorMode.Edit, x => $"{x.SomeProperty}, {x.OtherProperty}") (note the comma in the formatted string).
  2. Open the editor for an entity where the field is read-only.
    3.Observe that the read-only value renders with the comma in the label.
    4.Attempt to save the entity.

The UI shows the error “This field exceeds the allowed amount of items”, despite only one item being selected.

Expected behavior
The format function should be treated as a single display string. Commas inside the formatted value should not be interpreted as multiple items, and the picker should allow saving without error.

Environment (please complete the following information):
Umbraco CMS: 15.4.4
UI Builder: 15.1.9

Additional context
Removing the comma from string before sending it off resolves the issue, but I would love to see if this could be resolved.

Thanks!!!!


This item has been added to our backlog AB#56646

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions