Skip to content

Commit

Permalink
Move Character count attributes to formGroup wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Jan 10, 2024
1 parent 58e92b6 commit 341017b
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#}
{%- set attributes = [] -%}

{% for attribute, value in params.formGroup.attributes %}
{% set attributes = (attributes.push([attribute, value]), attributes) %}
{% endfor %}

{%- if params.maxlength %}{% set attributes = (attributes.push(["data-maxlength", params.maxlength]), attributes) %}{% endif -%}
{%- if params.threshold %}{% set attributes = (attributes.push(["data-threshold", params.threshold]), attributes) %}{% endif -%}
{%- if params.maxwords %}{% set attributes = (attributes.push(["data-maxwords", params.maxwords]), attributes) %}{% endif -%}
Expand Down Expand Up @@ -72,7 +76,7 @@
}) }}
{% endset -%}

<div class="govuk-character-count" data-module="govuk-character-count" {%- for attribute, value in attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
<div class="govuk-character-count" data-module="govuk-character-count">
{{ govukTextarea({
id: params.id,
name: params.name,
Expand All @@ -82,7 +86,7 @@
value: params.value,
formGroup: {
classes: params.formGroup.classes,
attributes: params.formGroup.attributes,
attributes: attributes,
afterHtml: countMessageHtml
},
classes: 'govuk-js-character-count' + (' ' + params.classes if params.classes),
Expand Down

0 comments on commit 341017b

Please sign in to comment.