Sha256: bacf5c0cec59a55d18598d399233c73b8b46065de22124748ebcb62a1f5c5464

Contents?: true

Size: 1.54 KB

Versions: 14

Compression:

Stored size: 1.54 KB

Contents

<%
  add_gem_component_stylesheet("fieldset")

  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)

  text = text || yield
  describedby ||= nil
  role ||= nil
  heading_level ||= nil
  heading_size = false unless shared_helper.valid_heading_size?(heading_size)
  error_message ||= nil
  error_id ||= nil

  if error_message
    error_id = "error-#{SecureRandom.hex(4)}" unless error_id
    describedby = error_id
  end

  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(**component_helper.all_attributes) do %>
  <%= tag.fieldset class: fieldset_classes, aria: { describedby: describedby }, role: role do %>
    <% if heading_level %>
      <%= tag.legend class: legend_classes do %>
        <%= content_tag(
              shared_helper.get_heading_level,
              legend_text,
              class: "govuk-fieldset__heading"
            )
        %>
      <% end %>
    <% else %>
      <%= tag.legend legend_text, class: legend_classes %>
    <% end %>
    <% if error_message %>
      <%= render "govuk_publishing_components/components/error_message", {
        text: error_message,
        id: error_id
      } %>
    <% end %>
    <%= text %>
  <% end %>
<% end %>

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
govuk_publishing_components-51.1.0 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-51.0.0 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-50.0.1 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-50.0.0 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-49.1.0 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-49.0.0 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-48.0.0 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-47.0.0 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-46.4.0 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-46.3.1 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-46.3.0 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-46.2.0 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-46.1.0 app/views/govuk_publishing_components/components/_fieldset.html.erb
govuk_publishing_components-46.0.0 app/views/govuk_publishing_components/components/_fieldset.html.erb