Exception Error when container having space in htmlId?
-
13-01-2021 - |
Question
I encounter this error when override empty.xml
Layout for custom theme
I got this error
1 exception(s): Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'container', attribute 'htmlId': [facet 'pattern'] The value 'page-content inset' is not accepted by the pattern '[a-zA-Z][a-zA-Z\d-_:]*'. Line: 21
Element 'container', attribute
htmlId
: 'page-content inset' is not a valid value of the atomic typehtmlIdentifierType
. Line: 21
when I tried to set container with Id having space
I want to know how it's works.
it's work fine when i change id from
page-content inset
topage-content-inset
Solution
The value of the htmlId
attribute must be matched by the regular expression [a-zA-Z][a-zA-Z\d-_:]
.
[a-zA-Z][a-zA-Z\d-_:]
means
- Start with a letter (uppercase or lowercase)
- rest of the characters can be:
- a letter (uppercase or lowercase)
- a digit (0 to 9)
- the character
-
(minus) - the character
_
(underscore) - the character
:
(colon)
That's it. You are not allowed to have spaces (or any other characters except the ones above) inside an id.