Sha256: e5200f9998c31ea0e334409cb81d97b80cb3d1f751a2e923a4f961624578381e

Contents?: true

Size: 1.92 KB

Versions: 14

Compression:

Stored size: 1.92 KB

Contents

<%
  model = options[:model]
  form  = options[:form]
  name  = options[:name]

  group_class_list = [ 'form-group',    options[:group_class] ]
  label_class_list = [ 'control-label', options[:label_class] ]
  field_class_list = [ 'input-group',   options[:field_class] ]
  input_class_list = [ 'form-control',  options[:input_class] ]
  error_class_list = [ 'text-danger',   options[:error_class] ]
  group_class_list << 'has-error' if model.errors[name].present?

  group_class = group_class_list.flatten.join ' '
  label_class = label_class_list.flatten.join ' '
  field_class = field_class_list.flatten.join ' '
  input_class = input_class_list.flatten.join ' '
  error_class = error_class_list.flatten.join ' '

  input_prefix = options[:input_prefix]
  input_suffix = options[:input_suffix]

  label_text   = options[:label_text]
  label_prefix = options[:label_prefix]
  label_suffix = options[:label_suffix]

  input_options = {
      class:    input_class_list,
      disabled: options[:disabled]
    }

  error_hidden = options[:error_hidden]

  choices = options[:choices]
  flags   = options[:options]||{}
%>

<div class='<%= group_class %>'>

  <%= form.label name, class: label_class do %><%= label_prefix %><%= label_text||model.class.human_attribute_name(name.to_sym) %><%= label_suffix %><% end %>

  <% if input_prefix.present? || input_suffix.present? %>

    <div class='<%= field_class %>'>

      <% if input_prefix.present? %>
        <span class='input-group-addon'><%= input_prefix %></span>
      <% end %>

      <%= form.select name, choices, flags, input_options %>

      <% if input_suffix.present? %>
        <span class='input-group-addon'><%= input_suffix %></span>
      <% end %>

    </div>

  <% else %>

    <%= form.select name, choices, flags, input_options %>

  <% end %>

  <% if model.errors[name].present? && !error_hidden %>
    <p class='<%= error_class %>'><%= model.errors[name].first %></p>
  <% end %>

</div>

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
repres-bootstrap-1.6 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.5.2 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.5.1 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.5 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.4 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.3.2 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.3.1 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.3 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.2 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.1 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.0.3 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.0.2 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.0.1 app/views/repres/bootstrap/_form_select_box.html.erb
repres-bootstrap-1.0 app/views/repres/bootstrap/_form_select_box.html.erb