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
20 def initialize(form, type, opts={})
21   @form, @type = form, type
22   defaults = form.input_defaults
23   @opts = (defaults.fetch(type){defaults[type.to_s]} || {}).merge(opts)
24   @form_opts = form.opts
25 end

Public Instance methods


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

[show source]
   # File lib/forme/input.rb
40 def format
41   Forme.transform(:formatter, @opts, @form_opts, self)
42 end
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
29 def tag(*a, &block)
30   form._tag(*a, &block)
31 end

Return a string containing the serialized content of the receiver.

[show source]
   # File lib/forme/input.rb
34 def to_s
35   Forme.transform(:serializer, @opts, @form_opts, self)
36 end