class Field::FormArray

Attributes

form_class[RW]

Public Instance Methods

attribute() click to toggle source
# File lib/field/form_array.rb, line 28
def attribute
  Array[@form_class]
end
inject_attributes() click to toggle source
# File lib/field/form_array.rb, line 9
def inject_attributes
  @container.attribute @name, attribute
end
inject_validations() click to toggle source
# 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