Sha256: c89cf50a973a270f798caaec23bcf7ec1994901f9d948c316ff4df11d8da3a71

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

<%
  index ||= false
  id ||= "checkbox-#{SecureRandom.hex(4)}"
  id = "#{id}-#{index}" if index
  controls ||= item[:conditional].present? ? "#{id}-conditional-#{index || rand(1..100)}" : nil
  name = item[:name].present? ? item[:name] : name
  margin_bottom ||= false
  margin_bottom_class = "gem-c-checkbox--margin-bottom" if margin_bottom
%>

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
govuk_publishing_components-12.21.0 app/views/govuk_publishing_components/components/_checkbox.html.erb
govuk_publishing_components-12.20.0 app/views/govuk_publishing_components/components/_checkbox.html.erb
govuk_publishing_components-12.19.0 app/views/govuk_publishing_components/components/_checkbox.html.erb
govuk_publishing_components-12.18.0 app/views/govuk_publishing_components/components/_checkbox.html.erb
govuk_publishing_components-12.17.0 app/views/govuk_publishing_components/components/_checkbox.html.erb
govuk_publishing_components-12.16.0 app/views/govuk_publishing_components/components/_checkbox.html.erb