Sha256: 77efc3233c300de55f791db7f651baa587f6a8d34dd3a0ee34389736e7b9cc34
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
module Formtastic class FormBuilder def localized_input(name, args = {}) t = self.object.send("#{name}_translations") field = ActiveAdmin::Mongoid::Localize::Field.new(self.object, name) self.semantic_fields_for "#{name}_translations", field do |lf| ::I18n.available_locales.each do |locale| args[:value] = (t.nil? || t[locale.to_s].nil?) ? '' : t[locale.to_s] label = CGI.escapeHTML(self.object.class.human_attribute_name(name)) + " #{template.image_tag "aml/flags/#{locale.to_s}.png", alt: locale.to_s, title: locale.to_s}" if args[:as] == :ckeditor form_buffers.last << "<h3 style='margin: 10px 0px 0px 10px;'>#{label}</h3>#{'<abbr>*</abbr>' if field.required?}".html_safe args[:label] = false else args[:label] = label.html_safe end args[:required] = field.required? form_buffers.last << lf.input(locale, args) form_buffers.last end end # return in case our input is last self.form_buffers.last end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activeadmin-mongoid-localize-0.2.2 | lib/activeadmin-mongoid-localize/formtastic.rb |
activeadmin-mongoid-localize-0.2.1 | lib/activeadmin-mongoid-localize/formtastic.rb |