Sha256: 69a22de2337a37c96cc2aa0a926447576053bb50857b5c7257a5fdb012ad0206

Contents?: true

Size: 1.19 KB

Versions: 44

Compression:

Stored size: 1.19 KB

Contents

<%
  id ||= "error-summary-#{SecureRandom.hex(4)}"
  title ||= false
  description ||= false
  data_attributes ||= {}
  items ||= []
  title_id ||= "error-summary-title-#{SecureRandom.hex(4)}"
  if items.empty? && !title
    raise ArgumentError, "The error_summary component needs at least one item or a title in order to render."
  end
%>
<%= tag.div(
  class: "gem-c-error-summary govuk-error-summary",
  data: { module: "error-summary" }.merge(data_attributes),
  aria: { labelledby: title_id },
  role: "alert",
  tabindex: -1,
  id: id,
) do %>
  <% if title %>
    <h2 class="govuk-error-summary__title" id="<%= title_id %>">
      <%= title %>
    </h2>
  <% end %>
  <div class="govuk-error-summary__body">
    <% if description %>
      <p><%= description %></p>
    <% end %>
    <% if items.present? %>
      <ul class="govuk-list govuk-error-summary__list">
        <% items.each_with_index do |item, index| %>
          <li class="gem-c-error-summary__list-item">
            <% if item[:href] %>
              <%= link_to item[:text], item[:href] %>
            <% else %>
              <%= item[:text] %>
            <% end %>
          </li>
        <% end %>
      </ul>
    <% end %>
  </div>
<% end %>

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
govuk_publishing_components-16.26.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.25.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.24.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.23.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.22.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.21.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.20.1 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.20.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.19.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.18.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.17.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.16.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.15.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.14.1 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.14.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.13.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.12.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.11.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.10.1 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.10.0 app/views/govuk_publishing_components/components/_error_summary.html.erb