简体   繁体   中英

ActiveAdmin: how to have a text field instead a color picker to input a color?

Picture a rails app with a Flower model. The flowers table has a color column. This app uses ActiveAdmin. In the admin layer, I register the the Flower model.

app/admin/flower.rb

ActiveAdmin.register Flower do
  permit_params :color
end

If I edit an existing flower (or create a new one), ActiveAdmin will force me to edit the color with a color picker. I want to edit the color with a text field.

How should I go about it ?

I use Rails 4.1.4 and ActiveAdmin 1.1.0

You will need to override the form

  form do |f|
    inputs 'Details' do
      f.semantic_errors
      f.input :color, as: :text
    end

    f.actions
  end

For more information, please look at https://activeadmin.info/5-forms.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM