Sha256: ecea987389132f2dc5df6b4c4f07a678c69192b082ad4b0e013e0874d090a225
Contents?: true
Size: 1.18 KB
Versions: 5
Compression:
Stored size: 1.18 KB
Contents
module DynamicScaffold module Form module Item class GlobalizeFields < Base attr_reader :locales delegate :proxy_field, :notes?, :render_notes, :render, to: :@item def initialize(config, type, locales, options = {}) super(config, type, :translations_attributes, options) @locales = locales end def for(type, *args, &block) @item = Form::Item::Base.create(@config, type, *args, &block) end def strong_parameter { translations_attributes: [:id, :locale, @item.name] } end 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 def lang_attributes(classnames = nil) build_html_attributes(classnames) end def locale_errors(locale, record) record.errors.full_messages_for("#{@item.proxy_field.name}_#{locale}") end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems