CWIS Developer Documentation
Protected Attributes | List of all members
FormField Class Reference

Generator for HTML form fields. More...

Inheritance diagram for FormField:
Inheritance graph
[legend]

Protected Attributes

 $MyName
 
 $MyIsRequired
 
 $MyLabel
 
 $MyValue
 
 $MyValidFunc
 
 $MyValidMsgs
 

Setup/Initialization

 __construct ($Name, $IsRequired, $Label, $ValidFunc, $ValidMsgs)
 Object Constructor. More...
 

Accessors

 Name ($NewVal=NULL)
 Get or set the name. More...
 
 IsRequired ($NewVal=NULL)
 Get/set IsRequired. More...
 
 Label ($NewVal=NULL)
 Get or set the form field label as shown to the user. More...
 
 Value ($NewVal=NULL)
 Get or set the form field value. More...
 
 IsPassword ()
 Determine if this form field is a password form field. More...
 

Display

 PrintField ($DisplayErrorIndicator=FALSE)
 Print the form field label and generate input tags for this form field. More...
 
 PrintLabel ($DisplayErrorIndicator=FALSE)
 Print the label for this form field without generating the input tags. More...
 

Error Checking

 IsInvalidValue ($Value)
 Check the validity of the form field's value. More...
 
 GetInvalidValueMessage ($ErrorCode)
 Map an error code from IsInvalidValue to an error message. More...
 

Detailed Description

Generator for HTML form fields.

Definition at line 14 of file FormField.php.

Constructor & Destructor Documentation

FormField::__construct (   $Name,
  $IsRequired,
  $Label,
  $ValidFunc,
  $ValidMsgs 
)

Object Constructor.

Parameters
string$NameInternal name for this field, used in the HTML for the id attribute.
bool$IsRequiredWhether the form field is required.
string$LabelDisplay label for this field as shown to the user.
callback$ValidFuncA function to check the validity of input to this field. The function should return 0 for valid input.
array$ValidMsgsAn array of error messages, corresponding to the error codes returned by $ValidFunc.

Definition at line 32 of file FormField.php.

References $MyName.

Member Function Documentation

FormField::GetInvalidValueMessage (   $ErrorCode)

Map an error code from IsInvalidValue to an error message.

Parameters
int$ErrorCodeError code assumed to come from IsInvalidValue().
Returns
Returns a text string corresponding to the given error code.

Definition at line 184 of file FormField.php.

FormField::IsInvalidValue (   $Value)

Check the validity of the form field's value.

Parameters
string$ValueValue to check.
Returns
Returns 0 for valid input and a non-zero value for invalid input.

Definition at line 152 of file FormField.php.

References $MyValidFunc.

FormField::IsPassword ( )

Determine if this form field is a password form field.

Returns
Returns TRUE if this form field is a password field.

Definition at line 106 of file FormField.php.

FormField::IsRequired (   $NewVal = NULL)

Get/set IsRequired.

See also
Name Get or set the value that determines whether the form field is required.
Parameters
bool$NewValTRUE to make the form field required. This parameter is optional.
Returns
Returns TRUE if the form field is required.

Definition at line 76 of file FormField.php.

FormField::Label (   $NewVal = NULL)

Get or set the form field label as shown to the user.

Parameters
string$NewValNew value for the form field label.
Returns
Returns the current form field label.

Definition at line 86 of file FormField.php.

FormField::Name (   $NewVal = NULL)

Get or set the name.

In other words, the internal name for the id attribute.

Parameters
string$NewValNew value for the object's name. This parameter is optional.
Returns
Returns the current name.

Definition at line 63 of file FormField.php.

FormField::PrintField (   $DisplayErrorIndicator = FALSE)

Print the form field label and generate input tags for this form field.

Parameters
bool$DisplayErrorIndicatorDetermines whether error associated with this form field should be displayed. Set it to TRUE to display errors. This parameter is optional and defaults to FALSE.

Definition at line 122 of file FormField.php.

References PrintLabel().

FormField::PrintLabel (   $DisplayErrorIndicator = FALSE)

Print the label for this form field without generating the input tags.

Parameters
bool$DisplayErrorIndicatorDetermines whether error associated with this form field should be displayed. Set it to TRUE to display errors. This parameter is optional and defaults to FALSE.

Definition at line 134 of file FormField.php.

Referenced by CheckboxFormField\PrintField(), and PrintField().

Here is the caller graph for this function:

FormField::Value (   $NewVal = NULL)

Get or set the form field value.

In other words, the value attribute.

Parameters
mixed$NewValNew value for the form field value. This parameter is optional.
Returns
Returns the current form field value.

Definition at line 97 of file FormField.php.

Referenced by OptionFormField\PrintInput().

Here is the caller graph for this function:

Member Data Documentation

FormField::$MyIsRequired
protected

Definition at line 208 of file FormField.php.

FormField::$MyLabel
protected

Definition at line 209 of file FormField.php.

FormField::$MyName
protected

Definition at line 207 of file FormField.php.

Referenced by __construct().

FormField::$MyValidFunc
protected

Definition at line 211 of file FormField.php.

Referenced by IsInvalidValue().

FormField::$MyValidMsgs
protected

Definition at line 212 of file FormField.php.

FormField::$MyValue
protected

Definition at line 210 of file FormField.php.


The documentation for this class was generated from the following file: