ActiveAdmin将过滤器添加到表单 [英] ActiveAdmin add filter to form

查看:65
本文介绍了ActiveAdmin将过滤器添加到表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个活动的管理模型上具有一些属性,该属性可以具有很多不同的值,所以现在我使用复选框来显示它们:

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将过滤器添加到表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆