API
Variables
Methods
static int SortErrors(
array
$err1, array
$err2) Sorts errors according to order of elements inside errors element in config.xml
- Parameters:
-
array$err1 - error 1 to compare array$err2 - error 2 to compare
static array TrimFormVars(
array
$formVars)Returns array with trimmed form values
- Parameters:
-
array$formVars - associative array (i.e. $_POST or $_GET).
Constructor
- Parameters:
-
string$xml - path to XML configuration file.
Adds an error text to specified validation
- Parameters:
-
string$fieldName - field name -
string$validationId - validation name -
string$text - error text
Adds validation
- Parameters:
-
string$fieldName - name of field to validate -
string$validationId - id of validation(empty, zipcode, email, date etc.) -
array$options - array with validation params if neccessaray
Validates form variables
- Parameters:
-
array$formVars - associative array with variables to validate
Checks secret key in session and returns true if secret is ok.
After you have checked secret key call ClearSecret() or set $clearAfter parameter to true.
- Parameters:
-
bool$clearAfter - if true secret key will be automaticly cleared
Clears secret key in session.
Important: This function must be called after each form submitting.
Returns true if field contains an error
- Parameters:
-
string$fieldName - field name
Returns an indexed string array with field names, which contain errors
Returns error text for specified field and error type
- Parameters:
-
string$field - form field specified in xml file in errors node -
string$errorType - string $errorType - type of error: empty / zipcode / any other specified in xml file
Returns an associative array with errors in following format:
ARRAY[FIELD_KEY] = FIELD_ERROR
Creates secret key in session and returns html code of hidden input element with secret key
Should be called with already existing session, or before any output
Returns a javascript config code for FormCheck JS class
- Parameters:
-
bool$jsEncode - if true json string will be returned
Manually registers an error for specified field
- Parameters:
-
string$fieldName - name of field -
string$errorType - type of error (regexp, date, or some other custom error)
Removes specified validation
- Parameters:
-
string$fieldName - name of field to validate -
string$validationId - id of validation(empty,zipcode,email,date etc.). If validationId is empty string, then all validations for specified field will be removed
Returns xml object with formcheck configuration (use ToString() method on this object to convert it to string).
- Parameters:
-
string$rootNodeName - name of root node.