This seems like it should be fairly simple, buy I haven't been able to find any documentation on the subject.
I have the following filter:
filter :archived, as: :select
...which gives me a working filter in the form of a select box with options "Any", "Yes", and "No".
My question is: How do I customize these labels such that the functionality remains the same, but the labels are instead "All", "Live", and "Archived"?
The quick and easy:
filter :archived, as: :select, collection: [['Live', 'true'], ['Archived', 'false']]
However, that won't give you a way to customize the "All" option without changing I18n.
UPDATED: Here's another option:
# Somewhere, in an initializer or just straight in your activeadmin file:
class ActiveAdmin::Inputs::FilterIsArchivedInput < ActiveAdmin::Inputs::FilterSelectInput
def input_options
super.merge include_blank: 'All'
end
def collection
[ ['Live', 'true'], ['Archived', 'false'] ]
end
end
# In activeadmin
filter :archived, as: :is_archived
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With