class Formalist::Elements::Section

Public Instance Methods

fill(input: {}, errors: {}) click to toggle source
Calls superclass method Formalist::Element::fill
# 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() click to toggle source

Converts the section into an abstract syntax tree.

It takes the following format:

“‘

:section, [params]

“‘

With the following parameters:

  1. Section name

  2. Custom form element type (or ‘:section` otherwise)

  3. Form element attributes

  4. Child form elements

@see Formalist::Element::Attributes#to_ast “Form element attributes” structure

@example “content” section

section.to_ast
# => [:section, [
  :content,
  :section,
  [:object, []],
  [...child elements...]
]]

@return [Array] the section as an abstract syntax tree.

# 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