Nesting Ruby on Rails HAML Checkbox in Label Tag

Posted by user1279116 on Stack Overflow See other posts from Stack Overflow or by user1279116
Published on 2012-03-19T17:06:23Z Indexed on 2012/03/19 18:04 UTC
Read the original article Hit count: 1106

Filed under:
|

I have the following code which doesn't work:

= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :class => "well" }) do |f|

= f.label :email
= f.email_field :email

= f.label :password
= f.password_field :password
- if devise_mapping.rememberable?
 %p
  = f.label :remember_me, :class => "checkbox" 
    = f.check_box :remember_me, :class => "checkbox"

  %div= f.submit "Einloggen"
= render :partial => "devise/shared/links"

It only works in that way, but I need it in one line and not in wto:

%p
  = f.label :remember_me, :class => "checkbox" 
  = f.check_box :remember_me, :class => "checkbox"

Please help! I'm really desprate right now. I just want the checkbox nested in the label for the bootsrap form. I searched google and stackoverflow but found nothing

UPDATE:

I solved it now like this:

- if devise_mapping.rememberable?
%p
  %label.checkbox{ :for => "remember_me" }
    = f.check_box :remember_me, :class => "checkbox"
    Remember 

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby