Sha256: 36e95ea40c55a4996f63ed77de1353dc8c82acfbb36b88b202dbb1474ce8443f

Contents?: true

Size: 942 Bytes

Versions: 1

Compression:

Stored size: 942 Bytes

Contents

module HungryForm
  module Elements
    # 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
    class Page < Base::Group
      attr_accessor :title

      hashable :title

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

      def to_s
        self.name
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hungryform-0.0.11 lib/hungryform/elements/page.rb