twitter_bootstrap_form_for icon indicating copy to clipboard operation
twitter_bootstrap_form_for copied to clipboard

Bootstrap-2.0 inputs have wrappers?

Open pareeohnos opened this issue 12 years ago • 8 comments

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

pareeohnos avatar Apr 18 '12 21:04 pareeohnos

Are you using Twitter Bootstrap 2?

stouset avatar Apr 20 '12 14:04 stouset

Sure am yeah.

pareeohnos avatar Apr 20 '12 14:04 pareeohnos

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

stouset avatar Apr 20 '12 14:04 stouset

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

pareeohnos avatar Apr 20 '12 14:04 pareeohnos

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.

stouset avatar Apr 20 '12 14:04 stouset

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

pareeohnos avatar Apr 20 '12 14:04 pareeohnos

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

stouset avatar Apr 20 '12 14:04 stouset

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 :)

pareeohnos avatar Apr 20 '12 14:04 pareeohnos