Sha256: ccd9b632272dfdc2a113c683a30af4615e5fd7e63ef16205f408618efb419371

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

<%
  add_gem_component_stylesheet("add-another")
  items ||= []
  empty ||= ""
  fieldset_legend ||= ""
  add_button_text ||= "Add another"
  empty_fields ||= false
%>

<%= tag.div class: "gem-c-add-another", data: {
  module: "add-another",
  "add-button-text": add_button_text,
  "fieldset-legend": fieldset_legend,
  "empty-fields": empty_fields
} do %>
  <% unless empty_fields && items.count == 0 %>
    <% items.each_with_index do |item, index| %>
      <%= render "govuk_publishing_components/components/fieldset", {
        classes: "js-add-another__fieldset",
        legend_text: "#{fieldset_legend} #{index + 1}",
        heading_size: "m"
      } do %>
        <div class="js-add-another__destroy-checkbox">
          <%= item[:destroy_checkbox] %>
        </div>
        <%= item[:fields] %>
      <% end %>
    <% end %>
  <% end %>
  <%= render "govuk_publishing_components/components/fieldset", {
    classes: "js-add-another__empty",
    legend_text: "#{fieldset_legend} #{items.length + 1}",
    heading_size: "m"
  } do %>
    <%= empty %>
  <% end %>
<% end %>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
govuk_publishing_components-51.1.0 app/views/govuk_publishing_components/components/_add_another.html.erb
govuk_publishing_components-51.0.0 app/views/govuk_publishing_components/components/_add_another.html.erb