Syed Raza
Syed Raza

Reputation: 1100

Formtastic Gems input check_boxes didn't support checked/selected list

Am using formtastics in Active Admin gem Everything is working find except one thing that am passing it list to be checked/selected on check boxes list but not working.. So kindly help me in this regard. Thanks..

I tried this in Simple form Its working fine over there but not in Formtastic.

<%= f.input :surgery_type_procedures, :label=>false,:as=>:check_boxes,:required=>false,:collection => st.surgery_type_procedures.all.collect!{ |p| [p.to_s, p.id] },:checked=>@surgery_type_procedures %>

<%= f.input :surgery_type_procedures, :label=>false,:as=>:check_boxes,:required=>false,:collection => st.surgery_type_procedures.all.collect!{ |p| [p.to_s, p.id] },:selected=>@surgery_type_procedures %>

Didn't Select Any check_box out which are in "@surgery_type_procedures" so kindly tell me is formtastic support checked or uncheck option??/

Upvotes: 1

Views: 828

Answers (2)

arturtr
arturtr

Reputation: 1115

Change p.id to p.id.to_s and remove checked/selected key. It should be works.

Upvotes: 0

Scott
Scott

Reputation: 2258

<%= f.input :column_name, :input_html => {:checked => 'checked'} %>

Upvotes: 1

Related Questions