Class Phorm

Description

Phorm

The abstract Phorm class wraps all of the functionality of the form itself. It is extended to created an HTML form. It specifies one abstract method: 'define_fields', which must set an attribute for each field in the form. Fields must be descendents of the PhormField class.

Located in /phorms.php (line 48)


	
			
Class Constant Summary
 GET = 0
 POST = 1
Variable Summary
mixed $bound
mixed $clean
mixed $data
mixed $errors
mixed $fields
mixed $method
mixed $multi_part
mixed $valid
Method Summary
void __construct ([Phorm::GET|Phorm::POST $method = Phorm::GET], [boolean $multi_part = false], [array $data = array()])
string as_list ()
string as_table ()
boolean check_if_bound ( $data)
array|null cleaned_data ()
null clean_data ()
string close ()
null define_fields ()
array find_fields ()
Iterator getIterator ()
array get_errors ()
boolean has_errors ()
boolean is_bound ()
boolean is_valid ([boolean $reprocess = false])
string open ([string $target = null])
null set_data ()
string __toString ()
Variables
mixed $bound = false (line 71)

True when the form has user-submitted data.

  • access: private
mixed $clean (line 89)

Private storage for cleaned field values.

  • access: private
mixed $data (line 77)

A copy of the superglobal data array merged with any default field values provided during class instantiation.

mixed $errors = array() (line 85)

Private storage to collect error messages. Stored as $field_name => $msg.

  • access: private
mixed $fields = array() (line 81)

Private field storage.

  • access: private
mixed $method = Phorm::GET (line 63)

The form's method. Determines which superglobal array to use as the data source.

  • access: private
mixed $multi_part = false (line 67)

If true, $_FILES is included in the form data. Makes possible file fields.

  • access: private
mixed $valid (line 94)

Memoized return value of the initial is_valid call.

Methods
Constructor __construct (line 103)
  • author: Jeff Ober
  • access: public
void __construct ([Phorm::GET|Phorm::POST $method = Phorm::GET], [boolean $multi_part = false], [array $data = array()])
  • Phorm::GET|Phorm::POST $method: whether to use GET or POST
  • boolean $multi_part: true if this form accepts files
  • array $data: initial/default data for form fields (e.g. array('first_name'=>'enter your name'))
as_list (line 386)

Returns the form fields as a series of list items. Does not include the list's opening and closing tags.

  • return: the HTML form
  • author: Jeff Ober
  • access: public
string as_list ()
as_table (line 366)

Returns the form fields as a series of HTML table rows. Does not include the table's opening and closing tags, nor the table's tbody tags.

  • return: the HTML form
  • author: Jeff Ober
  • access: public
string as_table ()
check_if_bound (line 174)

Returns true if any of the field's names exist in the source data (or

in $_FILES if this is a multi-part form.)

  • author: Jeff Ober
  • access: private
boolean check_if_bound ( $data)
  • array $data
cleaned_data (line 227)

Returns an associative array of the imported form data on a bound, valid form. Returns null if the form is not yet bound or if the form is not valid.

  • author: Jeff Ober
  • access: public
array|null cleaned_data ()
clean_data (line 291)

Processes each field's data in turn, calling it's get_value method to access its "cleaned" data.

  • author: Jeff Ober
  • access: private
null clean_data ()
close (line 344)

Returns the form's closing HTML tag.

  • return: the form's closing tag
  • author: Jeff Ober
  • access: public
string close ()
define_fields (line 166)

Abstract method that sets the Phorm's fields as class attributes.

  • author: Jeff Ober
  • abstract:
  • access: protected
null define_fields ()
find_fields (line 189)

Internal method used by the constructor to find all of the fields in the class after the child's 'define_fields' is called. Returns an array of the field instances.

  • return: the field instances
  • author: Jeff Ober
  • access: private
array find_fields ()
getIterator (line 303)

Returns an iterator that returns each field instance in turn.

  • author: Jeff Ober
  • access: public
Iterator getIterator ()
get_errors (line 258)

Returns the list of errors.

  • return: error messages
  • author: Jeff Ober
  • access: public
array get_errors ()
has_errors (line 248)

Returns true if the form has errors.

  • author: Jeff Ober
  • access: public
boolean has_errors ()
is_bound (line 238)

Returns true if the form is bound (i.e., there is data in the appropriate

superglobal array.)

  • author: Jeff Ober
  • access: public
boolean is_bound ()
is_valid (line 269)

Returns true if all fields' data pass validation tests.

  • author: Jeff Ober
  • access: public
boolean is_valid ([boolean $reprocess = false])
  • boolean $reprocess: if true (default: false), call all validators again
open (line 314)

Returns the form's opening HTML tag.

  • return: the form's opening tag
  • author: Jeff Ober
  • access: public
string open ([string $target = null])
  • string $target: the form target ($_SERVER['PHP_SELF'] by default)
set_data (line 213)

Sets the value of each field from the proper superglobal data array.

  • author: Jeff Ober
  • access: private
null set_data ()
__toString (line 355)

Returns a string of all of the form's fields' HTML tags as a table.

string __toString ()
Class Constants
GET = 0 (line 53)

Causes the form to use $_GET as its data source.

POST = 1 (line 57)

Causes the form to use $_POST as its data source.

Documentation generated on Mon, 20 Apr 2009 08:29:25 -0400 by phpDocumentor 1.4.2