Class: Field::FormArray
- Extended by:
- FormProxy
- Defined in:
- lib/field/form_array.rb
Instance Attribute Summary collapse
-
#form_class ⇒ Object
Returns the value of attribute form_class.
Attributes inherited from Base
Instance Method Summary collapse
Methods included from FormProxy
Methods inherited from Base
factory, #initialize, #presenter_class, #setup_container, #value
Constructor Details
This class inherits a constructor from Field::Base
Instance Attribute Details
#form_class ⇒ Object
Returns the value of attribute form_class.
7 8 9 |
# File 'lib/field/form_array.rb', line 7 def form_class @form_class end |
Instance Method Details
#attribute ⇒ Object
28 29 30 |
# File 'lib/field/form_array.rb', line 28 def attribute Array[@form_class] end |
#inject_attributes ⇒ Object
9 10 11 |
# File 'lib/field/form_array.rb', line 9 def inject_attributes @container.attribute @name, attribute end |
#inject_validations ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/field/form_array.rb', line 13 def inject_validations @container.class_eval %Q{ method = "__ensure_valid_#{name.to_s}__" validate method define_method method do #{name}.each_with_index do |form, i| unless form.send(:valid?) errors.add(:base, "Invalid #{name.to_s} on row \#\{i + 1\}") end end end } end |