简体   繁体   中英

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:

在此输入图像描述

But what I really want is a checklist like this:

在此输入图像描述

Any ideas?

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM