Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adjusted formtastic integration to work with 2.0.

Custom inputs in formtastic 2.0 work quite differently.
This quick solution might break use cases without
formtastic. Need to investigate further.
  • Loading branch information...
commit 12aba5fb945cf50ea3919b3ae774d9205a6cfcc4 1 parent d88527a
@oneiros oneiros authored
Showing with 11 additions and 20 deletions.
  1. +11 −20 lib/localized_language_select.rb
View
31 lib/localized_language_select.rb
@@ -117,25 +117,16 @@ def localized_language_select(method, priority_languages = nil, options = {}, ht
end
-module Formtastic #:nodoc:
-
- class SemanticFormBuilder < ActionView::Helpers::FormBuilder
-
- protected
-
- def language_input(method, options)
- html_options = options.delete(:input_html) || {}
- priority_languages = options.delete(:priority_languages) || []
-
- field_id = generate_html_id(method, "")
- html_options[:id] ||= field_id
- label_options = options_for_label(options)
- label_options[:for] ||= html_options[:id]
-
- label(method, label_options) <<
- localized_language_select(method, priority_languages, strip_formtastic_options(options), html_options)
- end
-
+class LanguageInput < Formtastic::Inputs::SelectInput
+
+ def collection
+ result = Array.new
+ priority_languages = input_options.delete(:priority_languages) || nil
+ if priority_languages
+ result += LocalizedLanguageSelect::priority_languages_array(priority_languages)
+ result << ["----------", ""]
+ end
+ result += LocalizedLanguageSelect::localized_languages_array(options)
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.