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
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | dots_display_modes-2170289-11.patch | 3.02 KB | plopesc |
| #9 | dots_display_modes-2170289-9.patch | 3.01 KB | plopesc |
| #9 | dots_display_modes-2170289-9-test-only.patch | 2.03 KB | plopesc |
| #1 | dots_display_modes-2170289-1.patch | 992 bytes | plopesc |
Comments
Comment #1
plopescThis 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.
Comment #3
tim.plunkett1: dots_display_modes-2170289-1.patch queued for re-testing.
Comment #4
internetdevels commentedLooks like it is the simplest way
Comment #5
plopescPatch 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:
Because the display mode machine_name is
entity_type.your_machine_nameRegards.
Comment #7
plopescNew patch addind tests to approach in #1
Comment #9
plopescRe-rolling
Comment #11
plopescRe-rolling
Comment #12
swentel commentedGreat thanks, RTBC when green.
Comment #13
alexpottThis 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!