FIX Update EditableFormHeading.php to output unique ID attributes to comply with accessibility standards

Fixes:

Multiple HeaderFields in UserForm creates WCAG Duplicate ID issue #1290

https://github.com/silverstripe/silverstripe-userforms/issues/1290
This commit is contained in:
Dan 2024-08-05 15:25:34 +12:00 committed by Daniel Cairns
parent 89db2fb2ae
commit c822f240af

View File

@ -70,7 +70,7 @@ class EditableFormHeading extends EditableFormField
public function getFormField() public function getFormField()
{ {
$labelField = HeaderField::create('userforms-header', $this->Title ?: false) $labelField = HeaderField::create('userforms-header-' . $this->ID, $this->Title ?: false)
->setHeadingLevel($this->Level); ->setHeadingLevel($this->Level);
$labelField->addExtraClass('FormHeading'); $labelField->addExtraClass('FormHeading');
$labelField->setAttribute('data-id', $this->Name); $labelField->setAttribute('data-id', $this->Name);