Class: Formalist::Elements::Section
- Inherits:
-
Formalist::Element
- Object
- Formalist::Element
- Formalist::Elements::Section
- Defined in:
- lib/formalist/elements/section.rb
Instance Attribute Summary
Attributes inherited from Formalist::Element
#attributes, #children, #errors, #input, #name
Instance Method Summary collapse
- #fill(input: {}, errors: {}) ⇒ Object
-
#to_ast ⇒ Array
Converts the section into an abstract syntax tree.
Methods inherited from Formalist::Element
#==, build, fill, #initialize, #type
Methods included from Formalist::Element::ClassInterface
#attribute, #attributes_schema, #type
Constructor Details
This class inherits a constructor from Formalist::Element
Instance Method Details
#fill(input: {}, errors: {}) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/formalist/elements/section.rb', line 8 def fill(input: {}, errors: {}) super( input: input, errors: errors, children: children.map { |child| child.fill(input: input, errors: errors) }, ) end |
#to_ast ⇒ Array
Converts the section into an abstract syntax tree.
It takes the following format:
[:section, [params]]
With the following parameters:
- Section name
- Custom form element type (or
:sectionotherwise) - Form element attributes
- Child form elements
43 44 45 46 47 48 49 50 |
# File 'lib/formalist/elements/section.rb', line 43 def to_ast [:section, [ name, type, Element::Attributes.new(attributes).to_ast, children.map(&:to_ast), ]] end |