activeadmin-searchable_select icon indicating copy to clipboard operation
activeadmin-searchable_select copied to clipboard

Support for Select2 tagging

Open dantevisser opened this issue 3 years ago • 1 comments

It would be great if users could be allowed to enter a new custom that's not in the collection to search for. Select2 seems to provide support for this via the "tagging" feature, but I'm unable to get it to work.

Thus far what I've tried:

filter(
  :foo,
  as: :searchable_select,
  collection: ['bar'],
  input_html: {
    tags: true
  }
)

I got this by looking at this SO answer https://stackoverflow.com/a/30021059

Original docs from Select2 on this feature: https://github.com/select2/select2/blob/develop/docs/pages/09.tagging/docs.md

I don't need complex logic for new tags, nor really ajax lookups or anything like that. The problem is I have a long list of string values and in some cases users would like to search on a value that's not in my list. I could simply change it to a plain input, but it's nice have some suggested values to search on.

I'd be more than happy to contribute a solution, I'm just not sure where to start.

dantevisser avatar Jan 25 '22 14:01 dantevisser

Sorry for being super late to respond. The activeadmin-select2 gem - which this gem is based on - appears to have some support for Select2 tags: https://github.com/mfairburn/activeadmin-select2/blob/master/lib/formtastic/inputs/select2_tags_input.rb. If you do not need the Ajax aspects, maybe using that might be a good fit?

tf avatar Apr 05 '22 08:04 tf