Module: ActiveAdmin::Globalize3::FormBuilderExtension
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_admin/globalize3/form_builder_extension.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#translated_inputs(name = "Translations", &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/active_admin/globalize3/form_builder_extension.rb', line 6 def translated_inputs(name = "Translations", &block) form_buffers.last << template.content_tag(:div, class: "activeadmin-translations") do template.content_tag(:ul, class: "available-locales") do I18n.available_locales.sort.map do |locale| template.content_tag(:li) do template.content_tag(:a, I18n.t(:"active_admin.globalize3.language.#{locale}"), href:".locale-#{locale}") end end.join.html_safe end << I18n.available_locales.sort.map do |locale| translation = object.translations.find_or_initialize_by_locale(locale) fields = proc do |form| form.input(:locale, as: :hidden) form.input(:id, as: :hidden) block.call(form) end inputs_for_nested_attributes( for: [:translations, translation ], class: "inputs locale locale-#{translation.locale}", &fields ) end.join.html_safe end end |