|
Cheetah
|
Public Member Functions | |
| __construct ($aInfo) | |
| initChecker ($aValues=array()) | |
| insert ($aValsToAdd=array()) | |
| update ($val, $aValsToAdd=array()) | |
| generateUri () | |
| getCleanValue ($sName) | |
| isSubmitted () | |
| isValid () | |
| isSubmittedAndValid () | |
| genCsrfToken ($bReturn=false) | |
| getCsrfTokenTime () | |
Static Public Member Functions | |
| static | getSubmittedValue ($sKey, $sMethod) |
| static | getCsrfToken () |
Public Attributes | |
| $_isValid = true | |
| $_sCheckerHelper | |
| $aFormAttrs | |
| $aTableAttrs | |
| $aInputs | |
| $aParams | |
| $id | |
Forms base class, consists of
Init form object examples:
$aForm = array(
'form_attrs' => array(
'name' => 'form_my',
'method' => 'post',
),
'params' => array (
'db' => array(
'table' => 'table_name', // table name
'key' => 'ID', // key field name
'uri' => 'EntryUri', // uri field name
'uri_title' => 'Title', // title field to generate uri from
'submit_name' => 'submit_form', // some filed name with non empty value to determine if the for was submitted,
in most cases it is submit button name
),
'csrf' => array(
'disable' => true, //if it wasn't set or has some other value then CSRF checking is enabled for current form, take a look at sys_security_form_token_enable to disable CSRF checking completely.
)
),
'inputs' => array(
'Title' => array(
'type' => 'text',
'name' => 'Title', // the same as key and database field name
'caption' => 'Some caption',
'required' => true,
// checker params
'checker' => array (
'func' => 'length', // see ChWsbFormCheckerHelper class for all check* functions
'params' => array(3,100),
'error' => 'length must be from 3 to 100 characters',
),
// database params
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see ChWsbFormCheckerHelper class for all pass* functions
),
),
'Description' => array(
'type' => 'textarea',
'name' => 'Description', // the same as key and database field name
'caption' => 'Some caption',
'required' => true,
// checker params
'checker' => array (
'func' => 'length',
'error' => 'enter at least 3 characters',
'params' => array(3,64000),
),
'db' => array (
'pass' => 'XssHtml', // do XSS clear, but keep HTML before getting this value
),
),
);
Example of using:
$oForm = new ChTemplFormView ($aForm);
$oForm->initChecker();
if ($oForm->isSubmittedAndValid ()) {
// add additional vars to database, in this case creation date field is added
$aValsAdd = array (
'Date' => time(),
);
echo 'insert last id: ' . $oForm->insert ($aValsAdd); // insert validated data to database
} else {
echo $oForm->getCode (); // show form
}
Definition at line 102 of file ChWsbForm.php.
| ChWsbForm::__construct | ( | $aInfo | ) |
Reimplemented in ChOAuthFormAdd, ChSitesFormSearch, ChTemplFormView, ChTemplFormView, ChTemplFormView, ChBaseFormView, and ChWsbFormMedia.
Definition at line 118 of file ChWsbForm.php.
| ChWsbForm::genCsrfToken | ( | $bReturn = false | ) |
Definition at line 270 of file ChWsbForm.php.
| ChWsbForm::generateUri | ( | ) |
Definition at line 225 of file ChWsbForm.php.
| ChWsbForm::getCleanValue | ( | $sName | ) |
Definition at line 232 of file ChWsbForm.php.
|
static |
Definition at line 289 of file ChWsbForm.php.
| ChWsbForm::getCsrfTokenTime | ( | ) |
Definition at line 295 of file ChWsbForm.php.
|
static |
Definition at line 258 of file ChWsbForm.php.
| ChWsbForm::initChecker | ( | $aValues = array () | ) |
Definition at line 150 of file ChWsbForm.php.
| ChWsbForm::insert | ( | $aValsToAdd = array() | ) |
Reimplemented in ChOAuthFormAdd.
Definition at line 176 of file ChWsbForm.php.
| ChWsbForm::isSubmitted | ( | ) |
Definition at line 243 of file ChWsbForm.php.
| ChWsbForm::isSubmittedAndValid | ( | ) |
Definition at line 253 of file ChWsbForm.php.
| ChWsbForm::isValid | ( | ) |
Definition at line 248 of file ChWsbForm.php.
| ChWsbForm::update | ( | $val, | |
$aValsToAdd = array() |
|||
| ) |
Definition at line 200 of file ChWsbForm.php.
| ChWsbForm::$_isValid = true |
Definition at line 104 of file ChWsbForm.php.
| ChWsbForm::$_sCheckerHelper |
Definition at line 105 of file ChWsbForm.php.
| ChWsbForm::$aFormAttrs |
Definition at line 107 of file ChWsbForm.php.
| ChWsbForm::$aInputs |
Definition at line 109 of file ChWsbForm.php.
| ChWsbForm::$aParams |
Definition at line 110 of file ChWsbForm.php.
| ChWsbForm::$aTableAttrs |
Definition at line 108 of file ChWsbForm.php.
| ChWsbForm::$id |
Definition at line 116 of file ChWsbForm.php.