XCube
The foundational Core of XoopsCube Legacy
 
Loading...
Searching...
No Matches
XCube_FieldProperty Class Reference

[Abstract] Used for validating member property values of XCube_ActionForm. More...

Public Member Functions

 __construct (&$form)
 Constructor.
 
 setDependsByArray ( $dependsArr)
 Initializes the list of validators for this field property with the list of dependency rule names.
 
 addMessage ( $name, $message)
 Adds an error message that will be used if the validation of the "$name" rule fails.
 
 renderMessage (string $name)
 Gets the error message rendered by XCube_Utils::formaString().
 
 addVar ( $name, $value)
 Adds a virtual variable used by validators.
 
 validate (&$form)
 Validates the form property with the validators that the field's property contains.
 

Data Fields

 $mForm
 XCube_ActionForm - Parent form contains this field property.
 
 $mDepends
 XCube_Validator[] - std::map<string, XCube_Validator*>
 
 $mMessages
 Complex Array.
 
 $mVariables
 Hash-Map Array - std::map<string, mixed>
 

Detailed Description

[Abstract] Used for validating member property values of XCube_ActionForm.

Constructor & Destructor Documentation

◆ __construct()

__construct ( & $form)

Constructor.

Parameters
XCube_ActionForm$form- Parent form.
Remarks
Only sub-classes of XCube_ActionForm calles this constructor.

Member Function Documentation

◆ addMessage()

addMessage ( $name,
$message )

Adds an error message that will be used if the validation of the "$name" rule fails.

Parameters
string$name- Dependent rule name.
string$message- Error message.
Returns
void

It's possible to add 3 or more parameters. These additional parameters are used by XCube_Utils\formatString().

$field->addMessage('required', "{0:ucFirst} is required.", "name");

This feature is helpful for automatic ActionForm generators.

◆ addVar()

addVar ( $name,
$value )

Adds a virtual variable used by validators.

Parameters
string$name- A name of the variable.
mixed$value- A value of the variable.

Virtual variables are used to be validated by validators. For example, XCube_MinlengthValidator needs a value indicating a minimum length.

$field->addVar('minlength', 2);

◆ renderMessage()

renderMessage ( string $name)

Gets the error message rendered by XCube_Utils::formaString().

Parameters
string$name- Dependent rule name.
Returns
string

Gets the error message registered at addMessage(). If the message parameter has arguments, these are rendered by XCube_Utils\formatString().

$field->addMessage('required', "{0:ucFirst} is required.", "name");
// Gets "Name is required."
$field->renderMessage('required');

This feature is helpful for automatic ActionForm generators.

◆ setDependsByArray()

setDependsByArray ( $dependsArr)

Initializes the list of validators for this field property with the list of dependency rule names.

Parameters
string[]$dependsArr
Returns
void

◆ validate()

validate ( & $form)

Validates the form property with the validators that the field's property contains.

Attention
Only XCube_ActionForm and its sub-classes should call this method.
Parameters
$form
Returns
null
Todo
This class already has an instance of a form property.

check empty block else

Field Documentation

◆ $mMessages

$mMessages

Complex Array.

Complex Array

$mMessages[$name]['message'] - string
$mMessages[$name]['args'][] - string

// Reference Define
typedef std::map<int, string> ArgumentMap;
struct MessageStorage
{
string Message;
ArgumentMap args;
};
typedef std::map<string, MessageStorage> MessageList;
MessageList mMessages;

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