Class: DynamicScaffold::Form::Item::GlobalizeFields
- Inherits:
-
Base
- Object
- Base
- DynamicScaffold::Form::Item::GlobalizeFields
show all
- Defined in:
- lib/dynamic_scaffold/form/item/globalize_fields.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#multiple, #name, #parent_item
Instance Method Summary
collapse
Methods inherited from Base
create, #default, #default_value, #errors, #if, #insert, #label, #label?, #needs_rendering?, #note, #notes?, #proxy, #proxy_field, #render_label, #render_notes, #type?, #unique_name, #unless
Constructor Details
#initialize(config, type, locales, options = {}) ⇒ GlobalizeFields
Returns a new instance of GlobalizeFields.
10
11
12
13
|
# File 'lib/dynamic_scaffold/form/item/globalize_fields.rb', line 10
def initialize(config, type, locales, options = {})
super(config, type, :translations_attributes, options)
@locales = locales
end
|
Instance Attribute Details
#locales ⇒ Object
Returns the value of attribute locales.
7
8
9
|
# File 'lib/dynamic_scaffold/form/item/globalize_fields.rb', line 7
def locales
@locales
end
|
Instance Method Details
23
24
25
26
27
28
29
30
|
# File 'lib/dynamic_scaffold/form/item/globalize_fields.rb', line 23
def (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) ⇒ Object
15
16
17
|
# File 'lib/dynamic_scaffold/form/item/globalize_fields.rb', line 15
def for(type, *args, &block)
@item = Form::Item::Base.create(@config, type, *args, &block)
end
|
#lang_attributes(classnames = nil) ⇒ Object
32
33
34
|
# File 'lib/dynamic_scaffold/form/item/globalize_fields.rb', line 32
def lang_attributes(classnames = nil)
build_html_attributes(classnames)
end
|
#locale_errors(locale, form) ⇒ Object
36
37
38
|
# File 'lib/dynamic_scaffold/form/item/globalize_fields.rb', line 36
def locale_errors(locale, form)
form.object.errors.full_messages_for("#{@item.proxy_field.name}_#{locale}")
end
|
#strong_parameter ⇒ Object
19
20
21
|
# File 'lib/dynamic_scaffold/form/item/globalize_fields.rb', line 19
def strong_parameter
{ translations_attributes: [:id, :locale, @item.name] }
end
|