Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveAdmin -- Show list of checkboxes for nested form instead of a form to add items

I have a nested form categories for stores resource. They have a has_and_belongs_to_many relationship.

When I create the nested form, I get the following on the stores form:

enter image description here

But what I really want is a checklist like this:

enter image description here

Any ideas?

like image 458
Hopstream Avatar asked Nov 11 '11 10:11

Hopstream


1 Answers

Turns out that after creating those relationships between the models, I don't need to do the f.has_many loop in the activeadmin resource. Instead, I just needed the following to make it work:

f.input :categories, :as => :check_boxes

This will automatically take the categories and check the default ones (and also handle any changes made to it).

like image 52
Hopstream Avatar answered Oct 05 '22 19:10

Hopstream