Lightnote CMS - web 2.0 content management system

API

Overview | API Reference
Variables
$errors = array()

Array with Variables

Type
array
$hasErrors

Indicates true if form has errors.

Type
bool
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).
FormCheck FormCheck( [string $xml = null])

Constructor

Parameters:
string $xml - path to XML configuration file.
void AddErrorText( string $fieldName, string $validationId, string $text)

Adds an error text to specified validation

Parameters:
string $fieldName - field name
string $validationId - validation name
string $text - error text
void AddValidation( string $fieldName, string $validationId, [array $options = array()])

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
bool Check( array $formVars)

Validates form variables

Parameters:
array $formVars - associative array with variables to validate
bool CheckSecret( [bool $clearAfter = false])

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
void ClearSecret( )

Clears secret key in session.

Important: This function must be called after each form submitting.

bool FieldHasError( string $fieldName)

Returns true if field contains an error

Parameters:
string $fieldName - field name
string[] GetErrorFields( )

Returns an indexed string array with field names, which contain errors

string GetErrorText( string $field, string $errorType)

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
string[] GetErrorTexts( )

Returns an indexed array with error texts

array GetErrorTextsAssoc( )

Returns an associative array with errors in following format:

ARRAY[FIELD_KEY] = FIELD_ERROR

string GetHiddenField( )

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

string GetJsConfig( [bool $jsEncode = true])

Returns a javascript config code for FormCheck JS class

Parameters:
bool $jsEncode - if true json string will be returned
void RegisterError( string $fieldName, string $errorType)

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)
void RemoveValidation( string $fieldName, [ string $validationId = ""] )

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
LN_Xml ToXml( [ $rootNodeName = "FormCheck"])

Returns xml object with formcheck configuration (use ToString() method on this object to convert it to string).

Parameters:
string $rootNodeName - name of root node.