PHP Class Prado\Web\UI\WebControls\TCustomValidator

TCustomValidator performs user-defined validation (either server-side or client-side or both) on an input component. To create a server-side validation function, provide a handler for the {@link onServerValidate OnServerValidate} event that performs the validation. The data string of the input control to validate can be accessed by {@link TServerValidateEventParameter::getValue Value} of the event parameter. The result of the validation should be stored in the {@link TServerValidateEventParameter::getIsValid IsValid} property of the event parameter. To create a client-side validation function, add the client-side validation javascript function to the page template. The function should have the following signature: Use the {@link setClientValidationFunction ClientValidationFunction} property to specify the name of the client-side validation script function associated with the TCustomValidator.
Since: 3.0
Author: Qiang Xue ([email protected])
Inheritance: extends TBaseValidator
Datei anzeigen Open project: pradosoft/prado Class Usage Examples

Public Methods

Method Description
evaluateIsValid ( ) : boolean This method overrides the parent's implementation.
getClientValidationFunction ( ) : string
getValidationTarget ( ) : TControl
onServerValidate ( $value ) : boolean This method is invoked when the server side validation happens.
setClientValidationFunction ( $value ) Sets the name of the custom client-side script function used for validation.

Protected Methods

Method Description
getClientClassName ( ) : string Gets the name of the javascript class responsible for performing validation for this control.
getClientScriptOptions ( ) : array Returns an array of javascript validator options.
registerClientScriptValidator ( ) Only register the client-side validator if {@link setClientValidationFunction ClientValidationFunction} is set.

Method Details

evaluateIsValid() public method

The validation succeeds if {@link onServerValidate} returns true.
public evaluateIsValid ( ) : boolean
return boolean whether the validation succeeds

getClientClassName() protected method

This method overrides the parent implementation.
protected getClientClassName ( ) : string
return string the javascript class name

getClientScriptOptions() protected method

Returns an array of javascript validator options.
protected getClientScriptOptions ( ) : array
return array javascript validator options.

getClientValidationFunction() public method

public getClientValidationFunction ( ) : string
return string the name of the custom client-side script function used for validation.

getValidationTarget() public method

public getValidationTarget ( ) : TControl
return TControl control to be validated. Null if no control is found.

onServerValidate() public method

It will raise the OnServerValidate event. The method also allows derived classes to handle the event without attaching a delegate. Note The derived classes should call parent implementation to ensure the OnServerValidate event is raised.
public onServerValidate ( $value ) : boolean
return boolean whether the value is valid

registerClientScriptValidator() protected method

Only register the client-side validator if {@link setClientValidationFunction ClientValidationFunction} is set.

setClientValidationFunction() public method

Sets the name of the custom client-side script function used for validation.
public setClientValidationFunction ( $value )