class Forme::Input

  1. lib/forme/input.rb
Superclass: Object

High level abstract tag form, transformed by formatters into the lower level Tag form (or an array of them).


Public Class

  1. new

Public Instance

  1. form
  2. form_opts
  3. format
  4. opts
  5. tag
  6. to_s
  7. type


form [R]

The Form object related to the receiver.

form_opts [R]

The options hash in use by the form at the time of the Input's instantiation.

opts [R]

The options hash for the Input.

type [R]

The type of input, should be a symbol (e.g. :submit, :text, :select).

Public Class methods

new (form, type, opts={})

Set the form, type, and opts.

[show source]
# File lib/forme/input.rb, line 19
def initialize(form, type, opts={})
  @form, @type = form, type
  defaults = form.input_defaults
  @opts = (defaults.fetch(type){defaults[type.to_s]} || {}).merge(opts)
  @form_opts = form.opts

Public Instance methods

format ()

Transform the receiver into a lower level Tag form (or an array of them).

[show source]
# File lib/forme/input.rb, line 39
def format
  Forme.transform(:formatter, @opts, @form_opts, self)
tag (*a, &block)

Create a new Tag instance with the given arguments and block related to the receiver's form.

[show source]
# File lib/forme/input.rb, line 28
def tag(*a, &block)
  form._tag(*a, &block)
to_s ()

Return a string containing the serialized content of the receiver.

[show source]
# File lib/forme/input.rb, line 33
def to_s
  form.raw_output(Forme.transform(:serializer, @opts, @form_opts, self))