Class: Formalist::Elements::Group
- Inherits:
-
Formalist::Element
- Object
- Formalist::Element
- Formalist::Elements::Group
- Defined in:
- lib/formalist/elements/group.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 group 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/group.rb', line 8 def fill(input: {}, errors: {}) children = self.children.map { |child| child.fill(input: input, errors: errors) } super(input: input, errors: errors, children: children) end |
#to_ast ⇒ Array
Converts the group into an abstract syntax tree.
It takes the following format:
[:group, [params]]
With the following parameters:
- Custom form element type (or
:group
otherwise) - Form element attributes
- Child form elements
41 42 43 44 45 46 47 |
# File 'lib/formalist/elements/group.rb', line 41 def to_ast [:group, [ type, Element::Attributes.new(attributes).to_ast, children.map(&:to_ast), ]] end |