diff --git a/packages/web-twig/src/Resources/components/Checkbox/Checkbox.twig b/packages/web-twig/src/Resources/components/Checkbox/Checkbox.twig index 15b7c12aaa..d4874283b9 100644 --- a/packages/web-twig/src/Resources/components/Checkbox/Checkbox.twig +++ b/packages/web-twig/src/Resources/components/Checkbox/Checkbox.twig @@ -30,19 +30,22 @@ {%- set _helperTextClassName = _spiritClassPrefix ~ 'Checkbox__helperText' -%} {%- set _validationTextClassName = _spiritClassPrefix ~ 'Checkbox__validationText' -%} -{# Attributes #} -{%- set _checkedAttr = _isChecked ? 'checked' : null -%} -{%- set _disabledAttr = _isDisabled ? 'disabled' : null -%} -{%- set _nameAttr = _name ? 'name="' ~ _name | escape('html_attr') ~ '"' : null -%} -{%- set _requiredAttr = _isRequired ? 'required' : null -%} -{%- set _valueAttr = _value ? 'value=' ~ _value : null -%} - {# Miscellaneous #} {%- set _styleProps = useStyleProps(props) -%} {%- set _classNames = [ _rootClassName, _rootDisabledClassName, _rootItemClassName, _rootValidationStateClassName, _styleProps.className ] -%} +{%- set _helperTextId = _helperText or _unsafeHelperText ? _id ~ '-helper-text' : null -%} {%- set _labelClassName = [ _labelClassName, _labelHiddenClassName, _labelRequiredClassName ] -%} {%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%} {%- set _allowedInputAttributes = [ 'autocomplete' ] -%} +{%- set _validationTextId = _validationText or _unsafeValidationText ? _id ~ '-validation-text' : null -%} + +{# Attributes #} +{%- set _ariaDescribedByAttr = _helperTextId or _validationTextId ? 'aria-describedby="' ~ [ _helperTextId, _validationTextId ] | join (' ') | trim ~ '"' : null -%} +{%- set _checkedAttr = _isChecked ? 'checked' : null -%} +{%- set _disabledAttr = _isDisabled ? 'disabled' : null -%} +{%- set _nameAttr = _name ? 'name="' ~ _name | escape('html_attr') ~ '"' : null -%} +{%- set _requiredAttr = _isRequired ? 'required' : null -%} +{%- set _valueAttr = _value ? 'value=' ~ _value : null -%}