Skip to content

Extra offset added in horizontal layout for input even when it has a label #130

@creativelycloudy

Description

@creativelycloudy

First, a big Thanks to everyone who created and works on this gem! It has become a staple in my projects.

Since a recent update (in the master branch), I'm seeing col-sm-offset-2's put in form-horizontal fields even if they have a label, this is throwing off my layout by bumping the input down about half a line.

Strangely, this seems to only happen after/if I manually add an f.form_group within my form (which I do a fair bit re: text blocks, check boxes, etc.)

_form.html.erb:

  <%= f.form_group do %>
    Some text or fields here...  
  <% end %>

  <%= f.text_field :postal, class: 'input-small', label: 'Postal', 
        disabled: disabled_unless?(:manager) %>

  <%= f.text_field :phone, class: 'input-small', label: 'Home',
        disabled: disabled_unless?(:manager) %>

HTML generated before merge:

<div class="form-group">
  <label class="control-label col-sm-2"></label>
  <div class="col-sm-10">
    Some text here...  
  </div>
</div>

<div class="form-group">
  <label class="control-label col-sm-2" for="property_postal">Postal</label>
  <div class="col-sm-10">
    <input class="form-control input-small" id="property_postal" name="property[postal]" type="text" value="M8V 3K4" />
  </div>
</div>

<div class="form-group">
  <label class="control-label col-sm-2" for="property_phone">Home</label>
  <div class="col-sm-10">
    <input class="form-control input-small" id="property_phone" name="property[phone]" type="text" value="(416)201-0355" />
  </div>
</div>

HTML generated after merge:

<div class="form-group">
  <div class="col-sm-10 col-sm-offset-2">
    Some text here...  
  </div>
</div>

<div class="form-group">
  <label class="control-label col-sm-2" for="property_postal">Postal</label>
  <div class="col-sm-10 col-sm-offset-2">
    <input class="form-control input-small" id="property_postal" name="property[postal]" type="text" value="M8V 3K4" />
  </div>
</div>

<div class="form-group">
  <label class="control-label col-sm-2" for="property_phone">Home</label>
  <div class="col-sm-10 col-sm-offset-2">
    <input class="form-control input-small" id="property_phone" name="property[phone]" type="text" value="(416)201-0355" />
  </div>
</div>

Notice the extra col-sm-offset-2 in the divs surrounding the inputs - even thought they have a label - in the after HTML. This makes the input column just a bit too wide (due to Bootstrap's CSS) and bumps the input down about half a line.

Again, this only seems to occur after I manually add an f.form-group prior to other f.fields.

Any help is much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions