ActiveAdmin将过滤器添加到表单

编程入门 行业动态 更新时间:2024-10-28 06:22:51
本文介绍了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将过滤器添加到表单

本文发布于:2023-11-09 17:22:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572973.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   过滤器   ActiveAdmin

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!