Sha256: 161402e97b9857e79b7d7e3d56c50e289c365b498f912506a41e13e428777751

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

<%
  model = options[:model]
  form  = options[:form]
  name  = options[:name]
  type  = options[:type]||:text_field

  label_class = [ 'control-label', options[:label_class]||'col-xs-2' ].flatten.join ' '
  field_class = [ options[:field_class]||'col-xs-10 input-group' ].flatten.join ' '
  error_class = [ options[:error_class]||'col-xs-offset-2 col-xs-10 text-danger' ].flatten.join ' '

  prefix = options[:prefix]
  suffix = options[:suffix]

  field_options = {
      disabled:    options[:disabled],
      class:       'form-control',
      placeholder: options[:placeholder],
      readonly:    options[:readonly],
      maxlength:   options[:maxlength],
      required:    options[:required]
    }
%>

<div class='form-group'>
  <%= form.label name, class: label_class %>
  <div class='<%= field_class %>'>
    <% if prefix.present? %>
      <span class='input-group-addon'><%= prefix %></span>
    <% end %>

    <%= form.send type, name, field_options %>

    <% if suffix.present? %>
      <span class='input-group-addon'><%= suffix %></span>
    <% end %>
  </div>
  <% if model.errors[name].present? %>
    <p class='<%= error_class %>'><%= model.errors[name].first %></p>
  <% end %>
</div>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unirer-bootstrap-0.2 app/views/unirer/bootstrap/_form_field.html.erb
unirer-bootstrap-0.1 app/views/unirer/bootstrap/_form_field.html.erb