Login |  Register 
Get your website developed the easy way
Your open source Rocks PHP Library has really made developing PHP easier!
Alan
 

RocksForm Class

Description

Implements interfaces:

  • RocksIValidatable

This represents a form on the page.

This simplifies common problems to do with form handling and validation.

  • author: Dominic Skinner
  • version: 0.2.1

Located in /RocksForm.php (line 15)


	
			
Method Summary
RocksForm __construct ()
void AddEqualToComparison (string $itemOne, string $itemTwo, string $message)
void AddField (string $name, string $type, string $isRequired, [string $formName = null], [string $default = null])
void AddFormIdentifier (string $fieldName, string $formName)
void AddItemOneGreaterThanTwoComparison (string $itemOne, string $itemTwo, string $message)
void AddItemOneLessThanTwoComparison (string $itemOne, string $itemTwo, string $message)
void AddNotEqualToComparison (string $itemOne, string $itemTwo, string $message)
void GetCurrentForm ()
void GetErrors ()
RocksFormField GetField (string $name)
void SetFormType (string $type)
void Validate ()
Methods
Constructor __construct (line 29)
  • access: public
RocksForm __construct ()
AddEqualToComparison (line 162)

Adds a equal to comparision. This checks that the values of the form fields are equal if they aren't then the message is displayed.

  • access: public
void AddEqualToComparison (string $itemOne, string $itemTwo, string $message)
  • string $itemOne: this is the name of the first field to compare
  • string $itemTwo: this is the name of the second field to compare
  • string $message: this is message that is displayed if the fields are not equal
AddField (line 134)

This method adds another field to the form. You need to add a field to the form to return the value in the associative array as well as to perform valudation on it.

  • access: public
void AddField (string $name, string $type, string $isRequired, [string $formName = null], [string $default = null])
  • string $name: this is the name of the form field
  • string $type: this is the type of the form field
  • string $isRequired: this indicates if the field is a required field
  • string $formName: this is the form name that field is part of. This isn't needed if there is only one form
  • string $default: this is the default value of the field if it is left empty.
AddFormIdentifier (line 81)

This adds a unique form identifier this indicates that a form field only belongs to one of the forms on the page. Note you only need to use this method if there are is more than one form on a page.

  • access: public
void AddFormIdentifier (string $fieldName, string $formName)
  • string $fieldName: this is the field name that uniquely identifies the form
  • string $formName: this is the form name that you want to assign to the form
AddItemOneGreaterThanTwoComparison (line 188)

Adds a item one is greater than item two comparision. This checks that the values of the form field item one is greater than item two if they aren't then the message is displayed.

  • access: public
void AddItemOneGreaterThanTwoComparison (string $itemOne, string $itemTwo, string $message)
  • string $itemOne: this is the name of the first field to compare
  • string $itemTwo: this is the name of the second field to compare
  • string $message: this is message that is displayed if the validation fails
AddItemOneLessThanTwoComparison (line 201)

Adds a item one is less than item two comparision. This checks that the values of the form field item one is less than item two if they aren't then the message is displayed.

  • access: public
void AddItemOneLessThanTwoComparison (string $itemOne, string $itemTwo, string $message)
  • string $itemOne: this is the name of the first field to compare
  • string $itemTwo: this is the name of the second field to compare
  • string $message: this is message that is displayed if the validation fails
AddNotEqualToComparison (line 175)

Adds a not equal to comparision. This checks that the values of the form fields are not equal if they aren't then the message is displayed.

  • access: public
void AddNotEqualToComparison (string $itemOne, string $itemTwo, string $message)
  • string $itemOne: this is the name of the first field to compare
  • string $itemTwo: this is the name of the second field to compare
  • string $message: this is message that is displayed if the fields are equal
GetAssociativeArrayData (line 43)

This returns a associative array with the field name as the key and the field value as the value.

  • access: public
void GetAssociativeArrayData ()
GetCurrentForm (line 106)

This returns the form that has just posted back.

  • access: public
void GetCurrentForm ()
GetErrors (line 209)

This returns a array of error messages. This also ensures that the form has been validated if this is called.

  • access: public
void GetErrors ()
GetField (line 145)

This method returns a field based on its name

  • access: public
RocksFormField GetField (string $name)
  • string $name: this is the name of the form field to return
SetFormType (line 66)

This sets the form type

  • access: public
void SetFormType (string $type)
  • string $type: this sets the type of form RocksPost or RocksGet
Validate (line 222)

This checks that all form fields pass all the validation tests.

  • access: public
void Validate ()

No comments have been provided.
security image

Written by Dominic Skinner
Last Updated: 2009-09-23 06:18:22