Class TForm

Description

Database-enabled TForm automatically loads and saves data

  • version: 09-02-2003 12:22
  • author: Greg MacLellan

Located in /form.inc.php (line 14)


	
			
Direct descendents
Class Description
TDBForm Database-enabled TForm automatically loads and saves data
Variable Summary
mixed $errors
mixed $extraFields
mixed $method
mixed $name
mixed $validated
Method Summary
TForm TForm (mixed $name, [mixed $method = "POST"])
True add ($object $object)
An getmd5 ()
An getNextLine ([bool $reset = false])
Mixed getValue (string $name)
An getValues ([bool $onlyStorable = true])
The html ()
void output ([$errors $errors = true], [mixed $noedit = false])
void restoreValues ()
True setError ($field $field, $error $error)
void setValue (mixed $name, mixed $value)
True validate ()
void wasSubmitted ()
Variables
mixed $errors = array() (line 24)

Any errors that occured during validation

mixed $extraFields (line 30)

Optional text output after <form..> for adding extra fields or whatever.

used by descendants.

mixed $method (line 18)

The form method

mixed $name (line 16)

The name of the form

mixed $validated = 0 (line 26)

If the form has been validated. One of FORM_STATE_*

Methods
Constructor TForm (line 35)
TForm TForm (mixed $name, [mixed $method = "POST"])
add (line 47)

Adds an object to the form

  • return: if the object was sucessfully added, or False if there is already an object with that name in the list.
True add ($object $object)
  • $object $object: An object to add (must be a descendant of TFormElement)
getDefaultValues (line 105)

Loads values passed in the GET string as default values.

Should be in the array _def[], indexed by field name

void getDefaultValues ()
getmd5 (line 294)

Generates an md5 that will uniquely identify the form, based on static

settings (ie values of data in the form will not affect the md5)

  • return: md5 representation of the whole form
An getmd5 ()
getNextLine (line 243)

Gets the next line for output, or resets it to the first element.

The first time this is called, it will return the first line, then the following lines.

  • return: array containing the values needed to output the line. "name": the name of the element, "type": the type (ie "text","button","textarea" etc), "label": the display name, "html": the html for the actual element (including value), "value": the current value by itself, "error": the error message, or blank if no error, "store": true the value is persistent,
An getNextLine ([bool $reset = false])
  • bool $reset: True to reset the form. No value will be returned.
getValue (line 339)

Returns the value of a field object

  • return: the value of the field
Mixed getValue (string $name)
  • string $name: The name of the field
getValues (line 307)

Gets the raw values for storing into database.

  • return: associative array of the storable values with their field names
An getValues ([bool $onlyStorable = true])
  • bool $onlyStorable: If we should only return storable values (default: true)
html (line 218)

Displays the basic opening <form> tag and hidden fields for form backend.

  • return: tags to display
The html ()
output (line 166)

Generically outputs the form. Usually you will use the other output functions to display a form mixed with your own HTML. This code can provide a good foundation, however.

void output ([$errors $errors = true], [mixed $noedit = false])
  • $errors $errors: True if you want to display errors, False otherwise
restoreValues (line 79)

Restores existing values to the form from submitted values

void restoreValues ()
setError (line 149)

Manually generate an error for a form field

Sets the form error field to the specified text, and sets the form state to invalid

  • return: if the error was set, false if the field doesn't exist
True setError ($field $field, $error $error)
  • $field $field: The field name to generate error for
  • $error $error: The error text
setValue (line 361)
void setValue (mixed $name, mixed $value)
validate (line 122)

Validates all the data in the form, and if there are any errors

stores them in $this->errors

  • return: if the form data is valid, False otherwise
True validate ()
wasSubmitted (line 278)

Checks if this form was submitted already

void wasSubmitted ()

Documentation generated on Thu, 27 Nov 2003 14:59:00 -0500 by phpDocumentor 1.2.3