Formtastic doesn’t have a simple solution for the “select all” checkbox, if you use JQUERY you can do it
In your student.rb model add
attr_accessor :select_all_courses f.inputs "Courses" do f.input :select_all_courses, :as => :boolean, :label => 'SELECT ALL', :input_html => {:onclick => "jQuery.each( $('.student_courses_checkboxes'), function() { this.checked = $('.all_selector')[0].checked });", :class => "all_selector"} f.input :courses, :as => :check_boxes, :collection => @courses, :input_html => {:class => 'student_courses_checkboxes'} end
The best you can do in active admin with formtastic:
In the form of a course
f.input :students, :as => :check_boxes, :collection => @students
source share