diff --git a/src/helpers/Cp.php b/src/helpers/Cp.php index fe1ab937256..5aa67bab426 100644 --- a/src/helpers/Cp.php +++ b/src/helpers/Cp.php @@ -1541,27 +1541,21 @@ public static function fieldHtml(string|callable $input, array $config = []): st $labelHtml = ''; } - $containerTag = $fieldset ? 'fieldset' : 'div'; - return - Html::beginTag($containerTag, ArrayHelper::merge( + Html::beginTag('div', ArrayHelper::merge( [ 'class' => $fieldClass, 'id' => $fieldId, + 'aria' => [ + 'labelledby' => $fieldset ? $labelId : null, + ], + 'role' => $fieldset ? 'group' : null, 'data' => [ - 'attribute' => $attribute, - ] + $data, + 'attribute' => $attribute, + ] + $data, ], $config['fieldAttributes'] ?? [] )) . - (($label && $fieldset) - ? Html::tag('legend', $labelHtml, [ - 'class' => ['visually-hidden'], - 'data' => [ - 'label' => $label, - ], - ]) - : '') . ($status ? Html::beginTag('div', [ 'id' => $statusId, @@ -1583,9 +1577,6 @@ public static function fieldHtml(string|callable $input, array $config = []): st 'id' => $labelId, 'class' => $config['labelClass'] ?? null, 'for' => !$fieldset ? $id : null, - 'aria' => [ - 'hidden' => $fieldset ? 'true' : null, - ], ], $config['labelAttributes'] ?? [])) : '') . (isset($config['labelExtra']) @@ -1616,7 +1607,7 @@ public static function fieldHtml(string|callable $input, array $config = []): st 'errors' => $errors, ]) : '') . - Html::endTag($containerTag); + Html::endTag('div'); } /**