Using the form helper for check boxes, I need to change the id
attribute. Normally I have something like this:
<%= f.label :remember_me, 'Please remember me' %>
<%= f.check_box :remember_me %>
Problem is, I'm already using another HTML element on the page with id="remember_me"
and this conflicts with that. So I tried changing this check_box
to:
<%= f.label :remember_me_top, 'me' %>
<%= f.check_box :remember_me_top, 'remember_me' %>
That gives me an error... How do I have the name
of the check box as remember_me, but the id
of it as remember_me_top?
You can change checkbox id like this:
<%= f.label :remember_me, 'Please remember me', :for => "my_unquie_id" %>
<%= f.check_box :remember_me, :id => "my_unquie_id" %>
Also, if you want to change name
attribute, add option to check_box: :name => "my_unique_name"