Skip to content

Support for Select2 tagging #37

@dantevisser

Description

@dantevisser

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions