diff --git a/packages/web-twig/src/Resources/components/Checkbox/Checkbox.twig b/packages/web-twig/src/Resources/components/Checkbox/Checkbox.twig index 4240ed88d1..7a46474136 100644 --- a/packages/web-twig/src/Resources/components/Checkbox/Checkbox.twig +++ b/packages/web-twig/src/Resources/components/Checkbox/Checkbox.twig @@ -33,6 +33,7 @@ {# 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 -%} @@ -53,10 +54,10 @@ {{ inputProps(props, _allowedInputAttributes, _inputProps) }} type="checkbox" id="{{ _id }}" - name="{{ _name }}" class="{{ _inputClassName }}" {{ _checkedAttr }} {{ _disabledAttr }} + {{ _nameAttr | raw }}" {{ _requiredAttr }} {{ _valueAttr }} {# Intentionally without `raw` to prevent XSS. #} /> diff --git a/packages/web-twig/src/Resources/components/Checkbox/__tests__/__fixtures__/checkboxDefault.twig b/packages/web-twig/src/Resources/components/Checkbox/__tests__/__fixtures__/checkboxDefault.twig index e22285addd..efd59c286c 100644 --- a/packages/web-twig/src/Resources/components/Checkbox/__tests__/__fixtures__/checkboxDefault.twig +++ b/packages/web-twig/src/Resources/components/Checkbox/__tests__/__fixtures__/checkboxDefault.twig @@ -1,3 +1,49 @@ -{% set inputProps = { "data-validate": "true" } %} + + + + + + + - + + + + + + + +{% set inputProps = { "data-validate": "true" } %} + diff --git a/packages/web-twig/src/Resources/components/Checkbox/__tests__/__snapshots__/checkboxDefault.twig.snap.html b/packages/web-twig/src/Resources/components/Checkbox/__tests__/__snapshots__/checkboxDefault.twig.snap.html index 95b5a8a881..cdd2990938 100644 --- a/packages/web-twig/src/Resources/components/Checkbox/__tests__/__snapshots__/checkboxDefault.twig.snap.html +++ b/packages/web-twig/src/Resources/components/Checkbox/__tests__/__snapshots__/checkboxDefault.twig.snap.html @@ -5,6 +5,19 @@ - + + + + + + + + + diff --git a/packages/web-twig/src/Resources/components/Checkbox/__tests__/__snapshots__/checkboxDefaultPure.twig.snap.html b/packages/web-twig/src/Resources/components/Checkbox/__tests__/__snapshots__/checkboxDefaultPure.twig.snap.html index 3891ffa6be..07555e2aa6 100644 --- a/packages/web-twig/src/Resources/components/Checkbox/__tests__/__snapshots__/checkboxDefaultPure.twig.snap.html +++ b/packages/web-twig/src/Resources/components/Checkbox/__tests__/__snapshots__/checkboxDefaultPure.twig.snap.html @@ -5,7 +5,7 @@ -