Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveAdmin filter boolean as single checkbox

How can i filter a boolean value using a single checkbox?

For example the following gives me two checkboxes with yes and no values:

ActiveAdmin.register User do    
  filter :is_retired, :as => :check_boxes
end

HBTM association is filtered as follows:

filter :roles_id, :as => :check_boxes, :collection => proc { Role.all }

But i have a boolean field in my User model and need a single checkbox with Is retired label. Is it possible somehow?

like image 448
roman Avatar asked Jul 25 '12 09:07

roman


2 Answers

filter :is_retired,
  as: :check_boxes,
  collection: [['Yes', true]],
  label: 'Retired?'
like image 164
Neeraj Kumar Avatar answered Nov 15 '22 08:11

Neeraj Kumar


As suggested elsewhere use filter :enabled, as: :select, collection: [["Yes", true], ["No", false]]

like image 24
Piers C Avatar answered Nov 15 '22 10:11

Piers C