Sha256: 6fbaa9bf11a966d1abe34c5548265dd13b83af3ed3c5523c4fc314563fbd7105
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true 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, form) form.object.errors.full_messages_for("#{@item.proxy_field.name}_#{locale}") end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dynamic_scaffold-2.0.1 | lib/dynamic_scaffold/form/item/globalize_fields.rb |
dynamic_scaffold-2.0.0 | lib/dynamic_scaffold/form/item/globalize_fields.rb |