Simple_form & Twitter Bootstrap: Form labels unaligned, missing HTML in production?
-
09-12-2019 - |
Question
When I go into production, my forms change causing the labels and fields to be unaligned from each other. In development it works correctly but not in production.
Here is what I mean:
Development
<div class="control-group string required">
<div class="control-label">
<label for="store_business_name" class="string required">
<abbr title="required">
*
</abbr> Business
</label>
</div>
<div class="controls">
<input type="text" size="50" name="store[business_name]" id="store_business_name" class="string required span3">
<p class="help-block">
The Business the store will belong to
</p>
</div>
</div>
Production
<div class="control-group string required">
<label for="store_business_name" class="string required">
<abbr title="required">
*
</abbr> Business
</label>
<div class="controls">
<input type="text" size="50" name="store[business_name]" id="store_business_name" class="string required span3">
<p class="help-block">
The Business the store will belong to
</p>
</div>
</div>
If you look closely, the <div class="control-label">
disappears in production. I'm not using any type of bootstrap gem (dependent on gems I can't install). Is this a known issue, how is this fixed?
<%= simple_form_for(@store, :html => { :class => 'form-horizontal' }) do |f| %>
<%= render :partial => "shared/error_message", :locals => { :f => f } %>
<div class="span12">
<%= f.input :business_name, :label => 'Business', :input_html => { :class => "span3" }, :hint => "The Business the store will belong to" %>
<%= f.input :online_store, :label => 'Online Store', :as => :boolean %>
<%= f.input :address, :input_html => { :class => "span3" }, :placeholder => "451 University Avenue, Palo Alto, CA 94301", :hint => "For offline store" %>
<%= f.input :website, :input_html => { :class => "span3" }, :placeholder => "www.somewebsite.com", :hint => "For online store" %>
<%= f.input :phone_number, :input_html => { :class => "span3" }, :placeholder => "(650) 798-2800" %>
<div class="form-actions">
<%= f.button :submit, "Done", :class => 'btn btn-primary span2' %>
</div>
</div>
<% end %>
Solution
What version of Simple_form are you using? How did you integrate bootstrap?
Presuming you used simple_form's wiki to integrate with twitter/bootstrap then please verify:
- lib/simple_form/contained_input_component.rb is being loaded and is implemented as-is
- config/initializers/simple_form.rb is calling the above library
- there is only one simple_form.rb in config/initializers and config/production
If all of the above is in order, please update the question with your view code.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow