简体   繁体   中英

Rails Active Admin - how to set up a form's with a drop down that includes X choices plus a “free” input

I would like to set up for an Active Admin form a field called field_example (string type), a basic dropdown that would show

  • option 1
  • option 2
  • option 3
  • freely inputed field

I would like to enable the user to choose of the 3 basic options but if he does not recognize himself in those 3 options, be able to type freely another string (this string would not have to be added to the list of options for future forms edition). He could type anything.

Is it possible?

My code today:

admin/model.rb

f.input :field_example,
        as:         :select,
        collection: LIST_OF_OPTIONS,
        prompt:     true

config/initializers/active_admin_constants

LIST_OF_OPTIONS = ["option1","option2", "option3"] 

ActiveAdmin(Formtastic)中没有什么可以帮助您解决此问题,但是ActiveAdmin经常使用的一个流行选项是Select2,它可能会有所帮助,例如, 选择2版本4.0允许用户输入自由文本

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