Nesting Ruby on Rails HAML checkbox in label shortcut

I have the following code that does not 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 this way, but I need this on a single line, not in wto:

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

Please, help! I'm really upset now. I just want the checkbox to be set in the shortcut for the bootsrap form. I searched google and stackoverflow but didn't find anything

UPDATE:

I solved it now as follows:

 - if devise_mapping.rememberable? %p %label.checkbox{ :for => "remember_me" } = f.check_box :remember_me, :class => "checkbox" Remember 
+4
source share
2 answers

What about:

 %p = f.label :remember_me, :class => "checkbox" do = f.check_box :remember_me, :class => "checkbox" 
+11
source

Use this:

 %p #{f.label :remember_me, :class => :checkbox} : #{f.check_box :remember_me, :class => :checkbox} 
0
source

Source: https://habr.com/ru/post/1402272/


All Articles