Home Rails Active Admin - how to set up a form's with a drop down that includes X choices plus a "free" input
Reply: 0

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

user894
1#
user894 Published in May 22, 2018, 4:36 am

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"] 
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.307403 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO