mbleigh / acts-as-taggable-on

A tagging plugin for Rails applications that allows for custom tagging along dynamic contexts.
http://mbleigh.lighthouseapp.com/projects/10116-acts-as-taggable-on
MIT License
4.97k stars 1.2k forks source link

Wrong simple_form syntax in wiki #797

Open gdgp opened 7 years ago

gdgp commented 7 years ago

In the wiki page Add a tag field to forms in Rails 4.2 and above

It is mentioned that:

If using simple_form, correct syntax is:

<%= f.text_field :tag_list, input_html: {value: f.object.tag_list.to_s} %>

However, as mentioned in the link provided in that very same page I think it should be f.input and not f.text_field

logicminds commented 7 years ago

isn't a text_field a type of input field?

toobulkeh commented 7 years ago

This is what finally worked for me (with select2-rails and SimpleForm):

= f.input :tag_list, collection: @tags, label: "Tags", value_method: :name, label_method: :name, input_html: { multiple: true, class: "js-tags-input tags-input" }
$(function() {
  $('.js-tags-input').select2({
    theme: 'bootstrap',
    tags: true,
    width: '100%'
  });
});
.tags-input {
  display: none;
}