Sha256: d2c72339388083346b359bd10b0b0647d5f2e60d3bfd1d9934557ac6aa0db69e

Contents?: true

Size: 836 Bytes

Versions: 2

Compression:

Stored size: 836 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.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.send(method) }
      text_area_without_globalize(method, options)
    end
  end
end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
radiant-globalize2-extension-0.2.1 lib/globalize2/form_builder_extensions.rb
radiant-globalize2-extension-0.2.0 lib/globalize2/form_builder_extensions.rb