我在一个活动的管理模型上具有一些属性,该属性可以具有很多不同的值,所以现在我使用复选框来显示它们:
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?
谢谢。
推荐答案是。查看 chosen_rails gem 。
在active_admin它看起来像这样:
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我唯一没有用check_boxes尝试过的东西,但是有 as::select ,它可以完美运行。我认为select会为您做同样的事情,因为您有倍数: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
更多推荐
ActiveAdmin将过滤器添加到表单
发布评论