Sha256: 1a43c662bd3d3087a75edbabdafcd2eb1e657238c8b786fb86736d5a3da6b88c

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

<%
  # name: formstrap/fields/list
  #
  # ==== Options
  # * +form+ - Form object
  # * +name+ - Name for the field
  # * +label+ - Text to show as label. Label will be hidden if value is false
  #
  # ==== Examples
  #   Basic version
  #   <%= render "formstrap/fields/list", form: form, name: :websites do |list| %#>
  #     <%= render "formstrap/fields/text", form: list, name: :url do |field, attribute, label| %#>
  #       <%= render "formstrap/text", form: field, attribute: attribute, label: label %#>
  #     <% end %#>
  #   <% end %#>

  label = local_assigns.has_key?(:label) ? label : nil
  show_label = label != false
%>

<%= render "formstrap/fields/base", form: form, name: name, field_type: :list do |list, field_label| %>
  <div class="mb-3">
    <%= render "formstrap/repeater", form: list, attribute: :fields, label: show_label ? label || field_label : false, flush: false do |field| %>

      <%= field.hidden_field :field_type, value: :list_item %>
      <%= field.hidden_field :name, value: :list_item %>

      <%= yield field %>
    <% end %>
  </div>
<% end %>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
formstrap-0.1.3 app/views/formstrap/fields/_list.html.erb
formstrap-0.1.2 app/views/formstrap/fields/_list.html.erb
formstrap-0.1.1 app/views/formstrap/fields/_list.html.erb
formstrap-0.1.0 app/views/formstrap/fields/_list.html.erb