Class: HungryForm::Elements::Page

Inherits:
Base::Group show all
Defined in:
lib/hungryform/elements/page.rb

Overview

Page is a main element of a form. Each page can include a page structure, defined in the block

A sample page could look like this:

page :about do
  html :before, value: "Please fill out the following fields"
  text_field :first_name
  text_field :last_name
end

The only required argument of a page is its name. You can specify a title and a label in the attributes like this:

page :about, title: “About me”, label: “About”

If there is no title or label specified, they will be created from the :name argument

Instance Attribute Summary collapse

Attributes inherited from Base::Group

#elements, #errors

Attributes inherited from Base::Element

#attributes, #dependency, #label, #name, #placeholders, #resolver, #visible

Instance Method Summary collapse

Methods inherited from Base::Group

#invalid?, #method_missing, #respond_to_missing?, #to_hash, #valid?

Methods inherited from Base::Element

#configuration, #dependency_json

Methods included from Base::Hashable

included, #to_hash

Constructor Details

#initialize(name, parent, resolver, attributes = {}, &block) ⇒ Page

Returns a new instance of Page.



25
26
27
28
# File 'lib/hungryform/elements/page.rb', line 25

def initialize(name, parent, resolver, attributes = {}, &block)
  super
  self.title = attributes[:title] || label
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class HungryForm::Elements::Base::Group

Instance Attribute Details

#titleObject

Returns the value of attribute title.



21
22
23
# File 'lib/hungryform/elements/page.rb', line 21

def title
  @title
end

Instance Method Details

#to_sObject



30
31
32
# File 'lib/hungryform/elements/page.rb', line 30

def to_s
  self.name
end