Nest TranslatableFormBuilder in helper module

To avoid having multiple top-level classes per file
This commit is contained in:
Marko Lovic
2018-08-23 12:32:36 +02:00
committed by Javi Martín
parent e26500179a
commit 5ad3bf03cd

View File

@@ -24,28 +24,28 @@ module TranslatableFormHelper
}
)
end
end
class TranslatableFormBuilder < FoundationRailsHelper::FormBuilder
class TranslatableFormBuilder < FoundationRailsHelper::FormBuilder
def translatable_text_field(method, options = {})
translatable_field(:text_field, method, options)
end
def translatable_text_field(method, options = {})
translatable_field(:text_field, method, options)
end
def translatable_text_area(method, options = {})
translatable_field(:text_area, method, options)
end
def translatable_text_area(method, options = {})
translatable_field(:text_area, method, options)
end
private
private
def translatable_field(field_type, method, options = {})
@template.capture do
@object.globalize_locales.each do |locale|
Globalize.with_locale(locale) do
final_options = @template.merge_translatable_field_options(options, locale)
@template.concat send(field_type, "#{method}_#{locale}", final_options)
def translatable_field(field_type, method, options = {})
@template.capture do
@object.globalize_locales.each do |locale|
Globalize.with_locale(locale) do
final_options = @template.merge_translatable_field_options(options, locale)
@template.concat send(field_type, "#{method}_#{locale}", final_options)
end
end
end
end
end
end
end