Class: Formalist::Elements::CompoundField
- Inherits:
-
Formalist::Element
- Object
- Formalist::Element
- Formalist::Elements::CompoundField
- Defined in:
- lib/formalist/elements/compound_field.rb
Instance Attribute Summary
Attributes inherited from Formalist::Element
#attributes, #children, #errors, #input
Instance Method Summary collapse
-
#initialize(*args, attributes, children, input, errors) ⇒ CompoundField
constructor
A new instance of CompoundField.
-
#to_ast ⇒ Array
Converts the compound field into an abstract syntax tree.
Methods inherited from Formalist::Element
Methods included from Formalist::Element::ClassInterface
attribute, attributes_schema, permitted_children, type
Constructor Details
#initialize(*args, attributes, children, input, errors) ⇒ CompoundField
Returns a new instance of CompoundField.
9 10 11 12 |
# File 'lib/formalist/elements/compound_field.rb', line 9 def initialize(*args, attributes, children, input, errors) super @children = children.map { |definition| definition.(input, errors) } end |
Instance Method Details
#to_ast ⇒ Array
Converts the compound field into an abstract syntax tree.
It takes the following format:
“‘
- :compound_field, [params]
-
“‘
With the following parameters:
-
Custom element type (or
:compound_fieldotherwise) -
Form element attributes
-
Child form elements
-
40 41 42 43 44 45 46 |
# File 'lib/formalist/elements/compound_field.rb', line 40 def to_ast [:compound_field, [ type, Element::Attributes.new(attributes).to_ast, children.map(&:to_ast), ]] end |