I have some properties on an active admin model, which can have a LOT of different values, so right now I'm displaying them using checkboxes:
PropertyType.find_each do |pt|
f.input :property_values
f.input :property_values, label: pt.display_name, as: :check_boxes, collection: pt.property_values.order(name: :asc, display_name: :asc).load , multiple: true
end
What I would like to do is to add an input field, in which while i'm writing, it filters the whole checkboxes list, only displaying the ones that matches the input field.
Is there a way to do that?
Thanks.
Yes. Check out chosen_rails gem .
In active_admin it will look something like this:
f.input :property_values,
label: pt.display_name,
as: :check_boxes,
collection: pt.property_values.order(name: :asc, display_name: :asc).load,
input_html: { class: 'chosen-select' },
multiple: true
The only thing I haven't tried it with check_boxes, but with as: :select
, and it works perfectly. I think select would be doing the same for you, since you have multiple: true
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.