stouset / twitter_bootstrap_form_for

A Rails FormBuilder DSL for generating Twitter Bootstrap forms
https://github.com/stouset/twitter_bootstrap_form_for
MIT License
409 stars 110 forks source link

Bootstrap-2.0 inputs have wrappers? #56

Open pareeohnos opened 12 years ago

pareeohnos commented 12 years ago

I'm trying to use this gem and I'm having a few minor issues with the markup that is being produced. I'm using the following code :

                        <%= home.label 'Address' do |controls| %> 
                <%= controls.text_field :home_name, :class => 'span3', :placeholder => "Building name/number" %>
                <%= controls.text_field :home_name, :class => 'span3', :placeholder => "Road" %>
                <%= controls.text_field :home_name, :class => 'span3', :placeholder => "Town" %>
                <%= controls.text_field :home_name, :class => 'span3', :placeholder => "County" %>
                <%= controls.text_field :home_name, :class => 'span2', :placeholder => "Postcode" %>
            <% end %>

Which is producing nearly the right format, however each of the input tags are being wrapped in a span with a class of input. So for example

<div class="control-group" id="field_control_group">
    <label class="control-label" for="field">Label</label>
    <div class="controls">
        <span class="input">
            <input class="span3" id="field" name="fields[field]" size="30" type="text" />
        </span>
    </div>
</div>

As a result, the bootstrap styling breaks and doesn't work the way it's meant to work. Is there any easy way to get rid of this or disable this?

Thanks

stouset commented 12 years ago

Are you using Twitter Bootstrap 2?

pareeohnos commented 12 years ago

Sure am yeah.

stouset commented 12 years ago

Use the bootstrap-2.0 branch. I need to fix a few remaining bugs and gemify it, but it should work.

pareeohnos commented 12 years ago

That's the branch I'm using? At least I should be? Certainly the output it's producing is in line with bootstrap-2.0 apart from the extra span. I'll grab it again and re-install and see if it helps

stouset commented 12 years ago

Ah, apologies. Have had a lot of bug reports from people still using the 1.3-compatible version. Can I see the full code for the form? You're missing the twitter_bootstrap_form_for line in your example.

pareeohnos commented 12 years ago

Ah fair enough. yeah sure thing, here you go


<%= twitter_bootstrap_form_for @CareHome, :html => { :class => "form-horizontal" } do |home| %>

        <%= home.fieldset do %>

            <div class="page-header">
                <h1>Sign Up <small>Register your care home</small></h1>
            </div>

            <%= home.text_field :home_name, :class => 'span3', :placeholder => "The name of your care home" %>

            <%= home.label 'Name' do |controls| %> 
                <%= controls.text_field :home_name, :class => 'span3', :placeholder => "The name of your care home" %>
            <% end %>

            <%= home.label 'Homepage' do |controls| %> 
                <%= controls.text_field :home_name, :class => 'span2', :placeholder => "The home page you would like", :add_on => :append do %>
                    <span class="add-on">.euphoricare.com</span>
                <% end %>
            <% end %>

            <%= home.label 'Address' do |controls| %> 
                <%= controls.text_field :home_name, :class => 'span3', :placeholder => "Building name/number" %>
                <%= controls.text_field :home_name, :class => 'span3', :placeholder => "Road" %>
                <%= controls.text_field :home_name, :class => 'span3', :placeholder => "Town" %>
                <%= controls.text_field :home_name, :class => 'span3', :placeholder => "County" %>
                <%= controls.text_field :home_name, :class => 'span2', :placeholder => "Postcode" %>
            <% end %>

            <%= home.actions do %>
                <%= home.submit 'Sign Up'%>
            <% end %>

        <% end %>
    <% end %>

I realise the form names are all the same but I'm just testing around with stuff

stouset commented 12 years ago

Looks reasonable to me. I'll try and figure out what's going on tonight. At work right now.

pareeohnos commented 12 years ago

That'd be fantastic thanks! I'm glad I'm not just doing something stupid. No hurry though, I can work around it for now :)