Sha256: cb7546d4dde494de4023a5d2ed408253c7af6e72f267fa2b0a52ec91c12d3c26

Contents?: true

Size: 825 Bytes

Versions: 2

Compression:

Stored size: 825 Bytes

Contents

<%
  id ||= "checkbox-#{SecureRandom.hex(4)}"
  index ||= rand(1..100)
  name = item[:name].present? ? item[:name] : name
%>

<%= tag.div class: "gem-c-checkbox govuk-checkboxes__item" do %>
  <%= tag.input id: "#{id}-#{index}",
    name: name,
    type: "checkbox",
    value: item[:value],
    class: "govuk-checkboxes__input",
    checked: item[:checked].present? ? "checked" : nil,
    aria: {
      describedby: item[:hint].present? ? "#{id}-#{index}-item-hint" : nil,
      controls: item[:conditional].present? ? "#{id}-conditional-#{index}" : nil
  } %>
  <%= tag.label item[:label], class: "govuk-label govuk-checkboxes__label", for: "#{id}-#{index}" %>
  <% if item[:hint].present? %>
    <%= tag.span item[:hint], id: "#{id}-#{index}-item-hint", class: "govuk-hint govuk-checkboxes__hint" %>
  <% end %>
<% end %>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
govuk_publishing_components-12.15.0 app/views/govuk_publishing_components/components/_checkbox.html.erb
govuk_publishing_components-12.14.1 app/views/govuk_publishing_components/components/_checkbox.html.erb