Sha256: 5362628928dfdf1f95e2905e86355e7474fa9483b3e99b45fe4557873e4ea74e

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

<%
  # name: formstrap/fields/group
  #
  # ==== Options
  # * +form+ - Form object
  # * +name+ - Name for the field
  # * +label+ - Text to show as label. Label will be hidden if value is false
  # * +named+ - Whether a group has to be wrapped around the passed block. If false, no group will be wrapped around the passed block.
  #
  # ==== Examples
  #   Basic version
  #   <%= render "formstrap/fields/group", form: form, name: :button do |group| %#>
  #     <div class="row">
  #       <div class="col-md-6">
  #         <%= render "formstrap/fields/text", form: group, name: :name do |field, attribute, label| %#>
  #           <%= render "formstrap/text", form: field, attribute: attribute, label: label %#>
  #         <% end %#>
  #       </div>
  #       <div class="col-md-6">
  #         <%= render "formstrap/fields/text", form: group, name: :url do |field, attribute, label| %#>
  #           <%= render "formstrap/text", form: field, attribute: attribute, label: label %#>
  #         <% end %#>
  #       </div>
  #     </div>
  #   <% end %#>

  label = local_assigns.has_key?(:label) ? label : nil
  wrapper = local_assigns.has_key?(:wrapper) ? local_assigns[:wrapper] : true
  named = local_assigns.has_key?(:named) ? local_assigns[:named] : true
  show_label = label != false
%>

<% if named %>
  <%= render "formstrap/fields/base", form: form, name: name, field_type: :group do |group, field_label| %>
    <% if show_label %>
      <%= render "formstrap/label", form: form, attribute: :value, text: label || field_label %>
    <% end %>

    <% if wrapper %>
      <ul class="list-group mb-3">
        <li class="list-group-item">
          <%= yield group %>
        </li>
      </ul>
    <% else %>
      <%= yield group %>
    <% end %>
  <% end %>

<% else %>
  <%= yield form %>
<% end %>

Version data entries

4 entries across 4 versions & 1 rubygems

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