What happened?
Description
The craft\helpers\Html::id() function was recently updated to strip out numbers at the beginning as a follow-up to #13943
The justification was that HTML IDs aren't allowed to begin with numbers. However, this was only the case in HTML 4. In HTML 5, there is no such restriction.
We're using this function to generate unique IDs for sections in our page builder matrix field. Those look like 123-section-name, where 123 is the entries' (previously matrix block's) ID and section-name is the headline. This string is truncated to a specific character length, so to ensure the entry ID is always part of the section ID, it needs to be at the start.
Steps to reproduce
- Call
craft\helpers\Html::id('123-custom-string')
Expected behavior
- The function should not strip out numbers at the beginning, as there is no reason for doing so to be standard-compliant.
Actual behavior
The function unexpectedly strips out numbers at the beginning.
Craft CMS version
5.1.6
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
What happened?
Description
The
craft\helpers\Html::id()function was recently updated to strip out numbers at the beginning as a follow-up to #13943The justification was that HTML IDs aren't allowed to begin with numbers. However, this was only the case in HTML 4. In HTML 5, there is no such restriction.
We're using this function to generate unique IDs for sections in our page builder matrix field. Those look like
123-section-name, where123is the entries' (previously matrix block's) ID andsection-nameis the headline. This string is truncated to a specific character length, so to ensure the entry ID is always part of the section ID, it needs to be at the start.Steps to reproduce
craft\helpers\Html::id('123-custom-string')Expected behavior
Actual behavior
The function unexpectedly strips out numbers at the beginning.
Craft CMS version
5.1.6
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions