Problem/Motivation

Entity Display modes creation pages (Form modes and View modes) allow to include dots in the machine_name textfield although it says:

A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.

Proposed resolution

Avoid the inclusion of dots in that textfield

Remaining tasks

Create patch

User interface changes

None

API changes

None

Comments

plopesc’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new992 bytes

This bug is due to the replace_pattern is modified to [^a-z0-9_.]+ in EntityDisplayModeAddForm to allow the dot included with the prefix eg: "node.".

This change is necessary to pass this validation when editing or deleting the display mode, however this change allow to enter extra dots in the machine name during entity creation.

To avoid this, this patch puts the default value again in Display mode creation form, in this way, user can't add dots in the entity add form, but included dot is allowed when the entity is edited or deleted.

Other way could be create a more complex regex which validates both cases. I tried it, but I was not able to reach it. Maybe someone with more experience could afford it.

Regards.

Status: Needs review » Needs work

The last submitted patch, 1: dots_display_modes-2170289-1.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
internetdevels’s picture

StatusFileSize
new706 bytes
new1.26 KB

Looks like it is the simplest way

plopesc’s picture

Patch in #4 does not work because is necessary allow dots for editing and deleting display modes.

If you test it manually, you'll get the following message in those cases:

The machine-readable name must contain only lowercase letters, numbers, and underscores.

Because the display mode machine_name is entity_type.your_machine_name

Regards.

The last submitted patch, 4: dots_display_modes-2170289-4.patch, failed testing.

plopesc’s picture

StatusFileSize
new2.03 KB
new3 KB
new2.03 KB

New patch addind tests to approach in #1

The last submitted patch, 7: dots_display_modes-2170289-7-test-only.patch, failed testing.

plopesc’s picture

The last submitted patch, 9: dots_display_modes-2170289-9-test-only.patch, failed testing.

plopesc’s picture

StatusFileSize
new3.02 KB

Re-rolling

swentel’s picture

Status: Needs review » Reviewed & tested by the community

Great thanks, RTBC when green.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed
Related issues: +#2100203: Make config entities use dots in machine names consistently

This is a slight dupe of #2100203: Make config entities use dots in machine names consistently

But this is nice a self contained and I'm happy to see this fixed :)

Committed d38ab8a and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.