aboutsummaryrefslogtreecommitdiffstats
path: root/app/inputs
diff options
context:
space:
mode:
authorjpl2017-04-04 15:44:50 +0200
committerjpl2017-04-04 15:44:50 +0200
commit2620efba52c5ce68ec9f0b812f387d7ef66c9d13 (patch)
tree9f5165302796d3b7def7a2c70c75ae1090b4c7b1 /app/inputs
parent043e813ce3c13be2611d20d5e084f2add79afb59 (diff)
downloadchouette-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.rb31
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