ValidForm::Text (Class)

In: ValidForm.rb
ValidForm_html.rb
Parent: Object

Represents a form field for text input. (May represent a single-line of input or an extended field for multiline input.)

See ::Field#new for details on the parameters to pass for a constructor.

  story = ValidForm::Text.new('story','story',nil,'Your sob story:',
              {:cols=>80, :rows=>10},
              {:minlength=>50, :maxlength=>2000, :required=>true}
          )
  story.multiline=true

For convenient inline creation, the ::Text object will set the multiline attribute to true if you put the symbol/value pair :multiline=>true in the attributes Hash during creation. (The pair will then be removed from the attributes Hash.)

  story = ValidForm::Text.new('story',nil,nil,'Your sob story:',
              {:cols=>80, :rows=>10, :multiline=>true },
              {:minlength=>50, :maxlength=>2000, :required=>true }
          )
  story.multiline  => true
  story.attributes => {:cols=>80, :rows=>10}

See also ::Password.

Methods

Attributes

multiline  [RW]  Does this field allow more than one line of text? false by default.

Public Instance methods

Returns an HTML representation of the field itself. See also ::Field#to_html. If name is nil, id is used for the name attribute.

  email = ValidForm::Text.new('email',nil,'Hello World')
  email.multiline    => false
  email.field_tohtml => '<span class="field"><input type="text" name="email" id="email" value="Hello World"></span>'

  email.multiline = true
  email.field_tohtml => '<span class="field"><textarea name="email" id="email">Hello World</textarea></span>'

[Validate]