Thursday, 15 September 2011

html - How to make the check box checked by default when using check_box_tag? -



html - How to make the check box checked by default when using check_box_tag? -

= form_tag movies_path, :id => 'ratings_form', :method => :get include: - @all_ratings.each |rating| = rating - is_checked = (!@selected_ratings.nil? && @selected_ratings.include?(rating)) = check_box_tag "ratings[#{rating}]", is_checked, is_checked, {:id => "ratings_#{rating}"} = submit_tag 'refresh', :id => 'ratings_submit'

ref :- check_box_tag

change

check_box_tag "ratings[#{rating}]", is_checked, is_checked, {:id => "ratings_#{rating}"}

to

check_box_tag "ratings[#{rating}]", is_checked, true, {:id => "ratings_#{rating}"}

html ruby-on-rails haml

No comments:

Post a Comment