Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Form Class Reference
[Form Abstraction]

Inheritance diagram for Form:

FormSync List of all members.

Detailed Description

Form.

This is the main form class that handles a variety of form tasks like adding / removing fields, setting layout, checking submission and validation status, etc.

Author:
Scott Peshak, Zach Smith

Definition at line 68 of file form.inc.php.

Public Member Functions

 __construct ($layout=null)
 Constructor.
 __get ($name)
 Magic getter.
 __set ($name, $value)
 Magic setter.
 add ($type, $name, array $options=array())
 Add a field to the form.
 getField ($name)
 get a field object from the form.
 replaceField ($type, $name, $options=array())
 replace a field in our form with a new one.
 addSubmit ($title= 'Submit')
 add a ButtonField of type submit with a title to the form (shortcut function)
 remove ($name)
 remove a field form the form (useful for modifying existing form objects
 isSubmitted ()
 Check to see if the form has been submitted.
 validate ()
 Validate all form fields.
 setData ($data)
 Set data.
 getData ($fieldName=null)
 Get the data.
 hasError ()
 Check all fields for an error.
 hasField ($field)
 Figure out if we have a field or not....
 needsDrawn ()
 Determine if we need our form drawn...
 isSubmittedAndValid ()
 a helper function that checks to see if its submitted, validates it, and then tells us if we have errors.
 drawIfNeeded ()
 shortcut function to draw the form if its needed: which is either not submitted or on error
 drawAll ($action=null, $submitText=null)
 Draw the form.
 draw ()
 draw the entire form
 setError ($fieldName, $errorString=null)
 Mark a field as having an error.
 getCss ()
 Get any special CSS styles that fields may define.
 assertFieldExists ($fieldName)
 Assert that a given field name actually exists in the form.

Static Public Member Functions

 autoload ($class)
 Magic function to load include files as needed.

Private Attributes

 $fields = array()
 Array of Field objects.
 $method = 'post'
 Request method to use, either post or get.
 $layout
 Layout object for displaying the form.
 $name
 Name of the form. Used with JavaScript.
 $action
 Url to post/get to.
 $onSubmit
 Url to post/get to.


Member Function Documentation

Form::__construct layout = null  ) 
 

Constructor.

Parameters:
$layout Optional Layout object to use

Reimplemented in FormSync.

Definition at line 81 of file form.inc.php.

Form::__get name  ) 
 

Magic getter.

Parameters:
$name 

Definition at line 100 of file form.inc.php.

Form::__set name,
value
 

Magic setter.

Parameters:
$name Name of member
$value Value to set

Reimplemented in FormSync.

Definition at line 113 of file form.inc.php.

Form::add type,
name,
array $  options = array()
 

Add a field to the form.

Parameters:
$type Field type (string).
$name Name of field.
$options Array of extra options.
Returns:
Reference to the added Field.

Definition at line 152 of file form.inc.php.

Form::addSubmit title = 'Submit'  ) 
 

add a ButtonField of type submit with a title to the form (shortcut function)

Parameters:
the title of the submit button
Returns:
a reference to the Field

Definition at line 201 of file form.inc.php.

Form::assertFieldExists fieldName  ) 
 

Assert that a given field name actually exists in the form.

Parameters:
$fieldName name to check

Definition at line 440 of file form.inc.php.

Form::autoload class  )  [static]
 

Magic function to load include files as needed.

Parameters:
$class Class name for which include is needed

Definition at line 452 of file form.inc.php.

Form::draw  ) 
 

draw the entire form

Definition at line 402 of file form.inc.php.

Form::drawAll action = null,
submitText = null
 

Draw the form.

Parameters:
$action value to use for form action.
$submitText Text to use for the submit button, if null then no buttons will be drawn
we will move to using only draw() in v2.2

Todo:
move all this to draw() in v2.2

Definition at line 366 of file form.inc.php.

Form::drawIfNeeded  ) 
 

shortcut function to draw the form if its needed: which is either not submitted or on error

Definition at line 352 of file form.inc.php.

Form::getCss  ) 
 

Get any special CSS styles that fields may define.

Returns:
string of CSS

Definition at line 426 of file form.inc.php.

Referenced by CollectionField::getCss().

Form::getData fieldName = null  ) 
 

Get the data.

Parameters:
$fieldName Name of single field to get data for
Returns:
Array of field name => value if $fieldName is null, value of field named $fieldName otherwise

Definition at line 277 of file form.inc.php.

Referenced by CollectionField::getData().

Form::getField name  ) 
 

get a field object from the form.

this is intended for you to be able to edit fields already added to a form.

Parameters:
$name the name of the field.
Returns:
the Field object, or false if it doesnt exist

Definition at line 171 of file form.inc.php.

Form::hasError  ) 
 

Check all fields for an error.

Returns:
boolean if the form has an error or not

Definition at line 299 of file form.inc.php.

Referenced by FormSync::handleSubmit(), and FormSync::handleSubmitWithCallback().

Form::hasField field  ) 
 

Figure out if we have a field or not....

Parameters:
$field the name of a field.
Returns:
boolean if it exists or not

Definition at line 314 of file form.inc.php.

Referenced by CollectionField::add().

Form::isSubmitted  ) 
 

Check to see if the form has been submitted.

Definition at line 225 of file form.inc.php.

Referenced by FormSync::handleSubmit(), and FormSync::handleSubmitWithCallback().

Form::isSubmittedAndValid  ) 
 

a helper function that checks to see if its submitted, validates it, and then tells us if we have errors.

saves 4-5 lines on common repetitive stuff.

Returns:
bool if the form is ready for post processing

Definition at line 335 of file form.inc.php.

Form::needsDrawn  ) 
 

Determine if we need our form drawn...

Returns:
boolean if its not submitted or has error

Definition at line 323 of file form.inc.php.

Form::remove name  ) 
 

remove a field form the form (useful for modifying existing form objects

Parameters:
$name the name of the field

Definition at line 213 of file form.inc.php.

Form::replaceField type,
name,
options = array()
 

replace a field in our form with a new one.

Parameters:
$type the type of field you want
$name the name of the field to replace
$options an array of field options like add

Definition at line 186 of file form.inc.php.

Form::setData data  ) 
 

Set data.

Parameters:
$data Either an array of field name => value, or a db result set

Definition at line 244 of file form.inc.php.

Referenced by CollectionField::setFieldsData().

Form::setError fieldName,
errorString = null
 

Mark a field as having an error.

Parameters:
$fieldName name of field to mark
$errorString error message to set

Definition at line 412 of file form.inc.php.

Form::validate  ) 
 

Validate all form fields.

Definition at line 233 of file form.inc.php.

Referenced by FormSync::handleSubmit(), FormSync::handleSubmitWithCallback(), and CollectionField::validate().


Member Data Documentation

Form::$action [private]
 

Url to post/get to.

Definition at line 74 of file form.inc.php.

Form::$fields = array() [private]
 

Array of Field objects.

Definition at line 70 of file form.inc.php.

Form::$layout [private]
 

Layout object for displaying the form.

Definition at line 72 of file form.inc.php.

Form::$method = 'post' [private]
 

Request method to use, either post or get.

Definition at line 71 of file form.inc.php.

Form::$name [private]
 

Name of the form. Used with JavaScript.

Definition at line 73 of file form.inc.php.

Form::$onSubmit [private]
 

Url to post/get to.

Definition at line 75 of file form.inc.php.


The documentation for this class was generated from the following file:
Generated on Fri Oct 27 12:26:41 2006 for BaseJumper by doxygen 1.3.9.1