Formtastic radio collection with hints

192 views Asked by At

I am working with Active Admin to create a form which has a radio collection.

form do |f|
  f.inputs "Options" do
    f.input :type, as: :radio, collection: Types.all.map{|type| [type.name, type.name]}
  end
end

I want to add a hint to each option in the radio collection. (A hint similar to a string input or various others).

What is the best way to go about this?

1

There are 1 answers

1
neo On

I would do it this way:

f.input :type, as: :radio, collection: Type.pluck(:name)

the method pluck is same as doing Type.all.map(&:name)

see http://apidock.com/rails/ActiveRecord/Calculations/pluck for more info.