class Formalist::ChildForms::ChildForm
Constants
- DEFAULT_INPUT_PROCESSOR
Public Instance Methods
attributes()
click to toggle source
Calls superclass method
# File lib/formalist/child_forms/child_form.rb, line 18 def attributes super.merge(form: form_attribute_ast) end
fill(input: {}, errors: {})
click to toggle source
Calls superclass method
# File lib/formalist/child_forms/child_form.rb, line 14 def fill(input: {}, errors: {}) super(input: form_input_ast(input), errors: errors.to_a) end
form_attribute_ast()
click to toggle source
# File lib/formalist/child_forms/child_form.rb, line 22 def form_attribute_ast @attributes[:form].to_ast end
form_input_ast(data)
click to toggle source
# File lib/formalist/child_forms/child_form.rb, line 26 def form_input_ast(data) # Run the raw data through the validation schema validation = @attributes[:schema].(data) # And then through the embedded form's input processor (which may add # extra system-generated information necessary for the form to render # fully) input = @attributes[:input_processor].(validation.to_h) @attributes[:form].fill(input: input, errors: validation.errors.to_h).to_ast end
to_ast()
click to toggle source
# File lib/formalist/child_forms/child_form.rb, line 38 def to_ast [:child_form, [ name, type, input, Element::Attributes.new(attributes).to_ast, ]] end