CWIS Developer Documentation

- Home
- Main Page
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Protected Attributes | List of all members
FormField Class Reference

Generator for HTML form fields. More...

Inheritance diagram for FormField:
[legend]

## Protected Attributes
| $MyName
| $MyIsRequired
| $MyLabel
| $MyValue
| $MyValidFunc
| $MyValidMsgs

## Setup/Initialization
| FormField ($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.

## Member Function Documentation

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

Object Constructor.

Parameters

  string | $Name | Internal name for this field, used in the HTML for the id attribute.
  bool | $IsRequired | Whether the form field is required.
  string | $Label | Display label for this field as shown to the user.
  callback | $ValidFunc | A function to check the validity of input to this field. The function should return 0 for valid input.
  array | $ValidMsgs | An array of error messages, corresponding to the error codes returned by `$ValidFunc`.

Definition at line 32 of file FormField.php.

References $MyName.

Referenced by CheckboxFormField\CheckboxFormField(), OptionFormField\OptionFormField(), and TextFormField\TextFormField().

Here is the caller graph for this function:

FormField::GetInvalidValueMessage | ( |  | $ErrorCode | ) |

Map an error code from IsInvalidValue to an error message.

Parameters

  int | $ErrorCode | Error code assumed to come from IsInvalidValue().

Returns
  Returns a text string corresponding to the given error code.

Definition at line 168 of file FormField.php.

FormField::IsInvalidValue | ( |  | $Value | ) |

Check the validity of the form field's value.

Returns
  Returns 0 for valid input and a non-zero value for invalid input.

Definition at line 136 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 94 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 | $NewVal | TRUE to make the form field required. This parameter is optional.

Returns
  Returns TRUE if the form field is required.

Definition at line 73 of file FormField.php.

FormField::Label | ( |  | $NewVal = `NULL` | ) |

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

Parameters

  string | $NewVal | New value for the form field label.

Returns
  Returns the current form field label.

Definition at line 80 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 | $NewVal | New 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 | $DisplayErrorIndicator | Determines 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 107 of file FormField.php.

References PrintLabel().

FormField::PrintLabel | ( |  | $DisplayErrorIndicator = `FALSE` | ) |

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

Parameters

  bool | $DisplayErrorIndicator | Determines 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 119 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 | $NewVal | New value for the form field value. This parameter is optional.

Returns
  Returns the current form field value.

Definition at line 88 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 192 of file FormField.php.

FormField::$MyLabel
| protected

Definition at line 193 of file FormField.php.

FormField::$MyName
| protected

Definition at line 191 of file FormField.php.

Referenced by FormField().

FormField::$MyValidFunc
| protected

Definition at line 195 of file FormField.php.

Referenced by IsInvalidValue().

FormField::$MyValidMsgs
| protected

Definition at line 196 of file FormField.php.

FormField::$MyValue
| protected

Definition at line 194 of file FormField.php.

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

- objects/FormField.php