Skip to content

Commit

Permalink
Add the component wrapper helper to fieldsets
Browse files Browse the repository at this point in the history
This allows classes to be passed to the fieldset component (needed for the add another component)
  • Loading branch information
dnkrj committed Nov 28, 2024
1 parent 34eeb91 commit ba5e235
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

* Add 'toggle' module to each expandable region in metadata component ([PR #4397](https://github.com/alphagov/govuk_publishing_components/pull/4397))
* Add a description for the metadata block 'see_updates_link' example ([PR #4447](https://github.com/alphagov/govuk_publishing_components/pull/4447))
* Add the component wrapper to the fieldset component ([PR #4420](https://github.com/alphagov/govuk_publishing_components/pull/4434))

## 45.9.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
describedby = error_id
end

css_classes = %w(gem-c-fieldset govuk-form-group)
css_classes << "govuk-form-group--error" if error_message
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-fieldset govuk-form-group")
component_helper.add_class("govuk-form-group--error") if error_message

fieldset_classes = %w(govuk-fieldset)

legend_classes = %w(govuk-fieldset__legend)
legend_classes << "govuk-fieldset__legend--#{heading_size}" if heading_size
%>
<%= tag.div class: css_classes do %>
<%= tag.div(**component_helper.all_attributes) do %>
<%= tag.fieldset class: fieldset_classes, aria: { describedby: describedby }, role: role, id: id do %>
<% if heading_level %>
<%= tag.legend class: legend_classes do %>
Expand Down

0 comments on commit ba5e235

Please sign in to comment.