Sha256: 2f47e59dab2e434919e78ad16f44fbcba1c4397bb6b151a7b928d828a973a6ca

Contents?: true

Size: 856 Bytes

Versions: 10

Compression:

Stored size: 856 Bytes

Contents

module Globalize2
  module FormBuilderExtensions
    def self.included(base)    
      base.alias_method_chain :text_field, :globalize
      base.alias_method_chain :text_area,  :globalize
    end
    
    def text_field_with_globalize(method, options = {})
      Rails.logger.debug "FormBuilder: text_field_with_globalize"
      options[:value] = options[:value] || I18n.with_locale(Globalize2Extension.content_locale) { object && object.send(method) }
      text_field_without_globalize(method, options)
    end
    
    def text_area_with_globalize(method, options = {})
      options[:value] = options[:value] || I18n.with_locale(Globalize2Extension.content_locale) { object && object.send(method) }
      text_area_without_globalize(method, options)
    end
  end
end

ActionView::Helpers::FormBuilder.send(:include, Globalize2::FormBuilderExtensions)

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
radiant-globalize2-extension-0.3.2 lib/globalize2/form_builder_extensions.rb
radiant-globalize2-extension-0.3.1 lib/globalize2/form_builder_extensions.rb
radiant-globalize2-extension-0.3.0 lib/globalize2/form_builder_extensions.rb
radiant-globalize2-extension-0.2.8 lib/globalize2/form_builder_extensions.rb
radiant-globalize2-extension-0.2.7 lib/globalize2/form_builder_extensions.rb
radiant-globalize2-extension-0.2.6 lib/globalize2/form_builder_extensions.rb
radiant-globalize2-extension-0.2.5 lib/globalize2/form_builder_extensions.rb
radiant-globalize2-extension-0.2.4 lib/globalize2/form_builder_extensions.rb
radiant-globalize2-extension-0.2.3 lib/globalize2/form_builder_extensions.rb
radiant-globalize2-extension-0.2.2 lib/globalize2/form_builder_extensions.rb