diff options
| author | jpl | 2017-04-04 15:44:50 +0200 |
|---|---|---|
| committer | jpl | 2017-04-04 15:44:50 +0200 |
| commit | 2620efba52c5ce68ec9f0b812f387d7ef66c9d13 (patch) | |
| tree | 9f5165302796d3b7def7a2c70c75ae1090b4c7b1 /app/inputs | |
| parent | 043e813ce3c13be2611d20d5e084f2add79afb59 (diff) | |
| download | chouette-core-2620efba52c5ce68ec9f0b812f387d7ef66c9d13.tar.bz2 | |
Refs #2892: adding simpleform builder for acts-as-taggable (for timetable#edit)
Diffstat (limited to 'app/inputs')
| -rw-r--r-- | app/inputs/tags_input.rb | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/app/inputs/tags_input.rb b/app/inputs/tags_input.rb index 4fbf0465f..1dc6129ee 100644 --- a/app/inputs/tags_input.rb +++ b/app/inputs/tags_input.rb @@ -1,19 +1,16 @@ -class TagsInput < Formtastic::Inputs::StringInput - - def to_html - input_wrapping do - label_html << - '<span id="tagsContainer"></span>'.html_safe << - builder.text_field(method, input_html_options) - end +class TagsInput < SimpleForm::Inputs::CollectionInput + enable :placeholder + + def input(wrapper_options = {}) + @collection ||= @builder.object.send(attribute_name) + label_method, value_method = detect_collection_methods + + merged_input_options = merge_wrapper_options(input_html_options, wrapper_options) + merged_input_options.reverse_merge!(multiple: true) + + @builder.collection_select( + attribute_name, collection, value_method, label_method, + input_options, merged_input_options + ) end - - def input_html_options - super.merge({ - :required => nil, - :autofocus => nil, - :class => 'tm-input', - }) - end - end |
