Sha256: 4afde7aaef0102577771ae9a259f831d3252cbca93e9d112962b65a2034dcf3c
Contents?: true
Size: 1.13 KB
Versions: 26
Compression:
Stored size: 1.13 KB
Contents
module Locomotive class LocaleInput < Formtastic::Inputs::TextInput include Formtastic::Inputs::Base::Choices def to_html input_wrapping do label_html << self.available_locales_to_html end end def available_locales_to_html template.content_tag(:div, Locomotive.config.locales.map do |locale| template.content_tag(:div, locale_to_html(locale).html_safe, class: 'entry') end.join.html_safe + template.content_tag(:div, '', class: 'clear'), class: 'list') end def locale_to_html(locale) text = I18n.t("locomotive.locales.#{locale}") builder.radio_button(:locale, locale, id: choice_input_dom_id(locale)) + template.content_tag(:label, template.image_tag("locomotive/icons/flags/#{locale}.png", alt: text, size: '24x24') + text, for: choice_input_dom_id(locale)) end def choice_input_dom_id(choice) [ builder.custom_namespace, sanitized_object_name, association_primary_key || method, choice_html_safe_value(choice) ].compact.reject { |i| i.blank? }.join("_") end end end
Version data entries
26 entries across 26 versions & 1 rubygems