class DynamicScaffold::Form::Item::GlobalizeFields

Attributes

locales[R]

Public Class Methods

new(config, type, locales, options = {}) click to toggle source
Calls superclass method DynamicScaffold::Form::Item::Base::new
# File lib/dynamic_scaffold/form/item/globalize_fields.rb, line 8
def initialize(config, type, locales, options = {})
  super(config, type, :translations_attributes, options)
  @locales = locales
end

Public Instance Methods

extract_parameters(permitting) click to toggle source
# File lib/dynamic_scaffold/form/item/globalize_fields.rb, line 21
def extract_parameters(permitting)
  trans = permitting.find {|item| item.is_a?(Hash) && item.key?(:translations_attributes) }
  if trans.nil?
    permitting << { translations_attributes: [:id, :locale, @item.name] }
  else
    trans[:translations_attributes] << @item.name
  end
end
for(type, *args, &block) click to toggle source
# File lib/dynamic_scaffold/form/item/globalize_fields.rb, line 13
def for(type, *args, &block)
  @item = Form::Item::Base.create(@config, type, *args, &block)
end
lang_attributes(classnames = nil) click to toggle source
# File lib/dynamic_scaffold/form/item/globalize_fields.rb, line 30
def lang_attributes(classnames = nil)
  build_html_attributes(classnames)
end
locale_errors(locale, form) click to toggle source
# File lib/dynamic_scaffold/form/item/globalize_fields.rb, line 34
def locale_errors(locale, form)
  form.object.errors.full_messages_for("#{@item.proxy_field.name}_#{locale}")
end
strong_parameter() click to toggle source
# File lib/dynamic_scaffold/form/item/globalize_fields.rb, line 17
def strong_parameter
  { translations_attributes: [:id, :locale, @item.name] }
end