two labels for checkboxes on boolean #920

Closed
optimum-dulopin opened this Issue Feb 19, 2013 · 8 comments

Projects

None yet

3 participants

@optimum-dulopin

Hi,
first thanks for this really great tool.
Im trying to have a simple checkbox on a boolean field
so I use
<%= u.input :display %> #display is a boolean field
but this render 2 labels, one in control-group and second in controls :
<div id="user_display_input" class="boolean input optional control-group"><label for="user_display" class=" control-label">display</label><input type="hidden" value="0" name="user[display]"><div class="controls"><label for="user_display" class=" checkbox"><input type="checkbox" value="1" name="user[display]" id="user_display" checked="checked">display</label></div>
</div>

is there a solution other than css to just have the second label ?

PS : on small other question, why to display a label for hidden field ? By default, would be before when u add a hidden field to have its label hidden too, no ?

thanks again

@justinfrench
Owner

@optimum-dulopin can I see the relevant ERB from your view and also the relevant HTML output, and how you expect the HTML to be different?

@optimum-dulopin

sorry, html code was not rendered. Now it is ok. And i would expect the same but without the first label, so somethins like this :
<div id="user_display_input" class="boolean input optional control-group"><input type="hidden" value="0" name="user[display]"><div class="controls"><label for="user_display" class=" checkbox"><input type="checkbox" value="1" name="user[display]" id="user_display" checked="checked">display</label></div>
</div>

here my current erb view
<%= semantic_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-vertical' }) do |u| %>
...
<%= u.input :display %>
...
<% end %>

@justinfrench
Owner

Where did the <div>s come from? Have you patched Formtastic, or are you using a plugin that modifies it?

@optimum-dulopin

im new in rails, so I didnt patched anything :-s
im using
gem 'formtastic'
gem 'formtastic-bootstrap'
is it what u meant ?

@justinfrench
Owner

@optimum-dulopin twitter-bootstrap basically patches/modifies Formtastic, changing the markup that's produced, so it's hard for me to tell if this is an issue with formtastic or formtastic-bootstrap. Any chance you can temporarily remove formtastic-bootstrap and validate if the markup issues are present in Formtastic alone?

@DylanFM
DylanFM commented Feb 26, 2013

I've just been experiencing this issue too. The app uses formastic along with formtastic-bootstrap. Disabling formtastic-bootstrap fixed the issue. I'll have a look over there :)

@DylanFM
DylanFM commented Feb 26, 2013

Here's a pull request fixing the issue, @optimum-dulopin:

mjbellantoni/formtastic-bootstrap#46

It doesn't appear to be in a release yet, but it has been merged into master.

@justinfrench
Owner

Thanks @DylanFM for looking into this, closing the issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment