Class FormValidator

(line 60)

Description

Object
   |
   --Persistent
      |
      --Component
         |
         --FormValidator

Located in File: /jsval/formvalidator.inc.php

This component provides an easy way to validate your form

Use this component to get an easy way to validate your form, by checking for specific data.

Rules for validation are stored on the Rules property, which is an array, in which every element is a rule to check.

After that, you can use javascript to call the validation function, which is named as the component plus _validate, for example fvValidate_validate().

That function shows any message if required and returns false if validation is not met, true otherwise.

  1.  <?php
  2.       function Unit464JSSubmit($sender$params)
  3.       {
  4.       ?>
  5.                return(fvValidate_validate());
  6.       <?php
  7.  
  8.       }
  9.  ?>



Properties

Summary:
Rules This property specifies the rules to validate the form
ValidateCompleteForm Specifies if the validation is to be perform on the complete for or field by field

Defined in class Component

Name Specifies the name for the component. The name is used as an identifier and should be unique.
Tag A versatile property of every Component that can be used in any way you want
ComponentCount Indicates the number of components owned by the component.
Components Lists all the components owned by this component.
ControlState A flag to know the state of the control, csLoading, csDesigning
DataFieldValue This property returns the value of the datafield if any.
NamePath Specifies the path to uniquely identify a component, qualified by the owner when required.
Owner Indicates the component that is responsible for streaming and freeing this component.

Defined in class Persistent

NamePath Used to serialize/unserialize. It returns the full path to identify this component.
Owner Owner of the component.

property Rules (line 101)

array Rules

This property specifies the rules to validate the form

Use this property to specify the validation rules to test against. In Delphi for PHP, there is a property editor you can use to setup this property, if you want do it in runtime, you can setup this array dynamically.

  1.  <?php
  2.   function Unit464BeforeShow($sender$params)
  3.   {
  4.    $rules=array();
  5.    $rules[]=array
  6.    (
  7.            'Control'=>'Edit1',
  8.            'Equals'=>'Edit2',
  9.            'ErrorMessage'=>'Edit1 and Edit2 must match and are required',
  10.            'Name'=>'FieldsMustMatch',
  11.            'Required'=>true,
  12.            'MaxLength'=>'0',
  13.            'MinLength'=>'0',
  14.            'MaxValue'=>'0',
  15.            'MinValue'=>'0'
  16.    );
  17.    $this->fvValidate->Rules=$rules;
  18.   }
  19.  ?>


property ValidateCompleteForm (line 116)

boolean ValidateCompleteForm

Specifies if the validation is to be perform on the complete for or field by field

If this property is set to true, all rules will be checked against the form, if false, will be checked from top to bottom and if one is not matched, the process will be aborted and a message will be shown.


property Name

Specifies the name for the component. The name is used as an identifier and should be unique.
This property is implemented in Component::Name

property Tag

A versatile property of every Component that can be used in any way you want
This property is implemented in Component::Tag

property ComponentCount

Indicates the number of components owned by the component.
This property is implemented in Component::ComponentCount

property Components

Lists all the components owned by this component.
This property is implemented in Component::Components

property ControlState

A flag to know the state of the control, csLoading, csDesigning
This property is implemented in Component::ControlState

property DataFieldValue

This property returns the value of the datafield if any.
This property is implemented in Component::DataFieldValue

property NamePath

Specifies the path to uniquely identify a component, qualified by the owner when required.
This property is implemented in Component::NamePath

property Owner

Indicates the component that is responsible for streaming and freeing this component.
This property is implemented in Component::Owner

property NamePath

Used to serialize/unserialize. It returns the full path to identify this component.
This property is implemented in Persistent::NamePath

property Owner

Owner of the component.
This property is implemented in Persistent::Owner

Methods

Summary:
__construct Component constructor [Overrides Component::__construct()]
dumpHeaderCode Dumps header code required [Overrides Component::dumpHeaderCode()]
dumpJavascript Dumps the javascript code needed by this component [Overrides Component::dumpJavascript()]

Defined in class Component

dumpChildrenJavascript Dumps the javascript code for all the children
dumpFormItems Dumps code just after the form tag, useful to dump hidden fields for state retrieving for non visible components
dumpHeaderCode Dumps header code required
dumpJavascript Dumps the javascript code needed by this component
hasValidDataField Returns true if a valid data field is attached to the component
init Initializes a component
loaded Initializes the component after the form file has been read into memory.
loadedChildren Calls childrens loaded
preinit Method called before init()
serializeChildren Serializes all children
unserializeChildren Unserializes all children by calling unserialize for all the components

Defined in class Persistent

serialize Stores this object into the session.
unserialize This method uses PHP reflection to iterate through published properties (the ones starting with get) and retrieve the properties stored by a previous serialize() call.

Defined in class Object

__construct Constructs an object and initializes its data before the object is first used.
className Returns a string indicating the type of the object instance (as opposed to the type of the variable passed as an argument).
classParent Returns the type of the immediate ancestor of a class.

Constructor __construct (line 62)

FormValidator __construct( [ $aowner = null])

Overrides : Component::__construct() Component constructor


Method dumpHeaderCode (line 135)

void dumpHeaderCode( )

Overrides : Component::dumpHeaderCode() Dumps header code required


Method dumpJavascript (line 121)

void dumpJavascript( )

Overrides : Component::dumpJavascript() Dumps the javascript code needed by this component


Events

Summary:

[none]

Javascript Events

Summary:

[none]

Documentation generated on Fri, 26 Dec 2008 11:45:24 +0100 by phpDocumentor 1.4.0a2