See https://github.com/argerim/select2-rails/issues/87.
I derived Select2TagsInput
from Formtastic::Inputs::StringInput
long time ago and forgot where to look, it was all there... For your interest:
# app/inputs/select2_tags_input.rb
class Select2TagsInput < Formtastic::Inputs::StringInput
def input_html_options
default_options = { width: '76%', tags: ActsAsTaggableOn::Tag.all.map(&:name) }
create_options = options[:create_options] || {}
create_options.merge!(default_options)
data = { create_options: create_options }
super.merge(:class => 'select2-input', data: data)
end
end
To specify custom create options, I do
f.input :keyword_list, as: :select2_tags, :create_options => { :tokenSeparators => [";"] }
which will now render correctly as
<input class="select2-input" data-create-options="{'tokenSeparators':[';'], 'tags':[...]}" id="item_keyword_list" name="item[keyword_list]" type="text" value="BlahBlah" />