Module: ActForm::Combinable

Extended by:
ActiveSupport::Concern
Defined in:
lib/act_form/combinable.rb

Instance Method Summary collapse

Instance Method Details

#combined_forms_valid?(context) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/act_form/combinable.rb', line 18

def combined_forms_valid?(context)
  return if _forms.empty?
  _forms.each do |form_class|
    form = form_class.new(attributes)
    form.valid?(context)
    form.errors.details.each do |attr_name, arr|
      arr.each do |error|
        next if error[:error] == :required
        errors.add(attr_name, error[:error])
      end
    end
  end
end

#valid?(context = nil) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
# File 'lib/act_form/combinable.rb', line 12

def valid?(context = nil)
  super
  combined_forms_valid?(context)
  errors.empty?
end