Define form data or rules
For form values and rules to be available for all apps, put them in inc/conf/properties.php, otherwise, put them in inc/your_app/conf/properties.php.
Warning: there is no $intl available when the global inc/conf/properties.php is loaded !
<?php
// Note: use intl_get only in app-level properties
formdata_set (
'sex',
array (
'male' => intl_get ('Male'),
'female' => intl_get ('Female'),
'unknow' => intl_get ('Unknow'),
)
);
// from inc/conf/properties.php:
formrules_set (
'username',
array (
array ('not empty', 'You must enter a username to continue.'),
array ('unique "sitellite_user/username"',
'The username you have chosen is already in use.'),
)
);
?>
Use them in a settings file
[sex]
type = select
setValues = "eval: formdata_get('sex')"
Or use them in the form class
<?php
$w =& $this->widgets['sex'];
$w->setValues (formdata_get ('sex'));
?>
Using predefined rules
To include predefined rules in your settings.php file:
[username]
type = text
setRules = "eval: formrules_get ('username')"
To include predefined rules in the constructor of your form class:
<?php
$w =& $this->widgets['username'];
$w->rules = formrules_get ('username');
?>
Note: As of Sitellite 4.2.0, there's no eval operator for rules in form settings files, however one will be added in 4.2.1. This means that formrules_get() can't be called in the settings.php file in Sitellite 4.2.0.
Revised on May 26, 2005 10:45 AM by electrolinux
Back in time (2 more) | Linked from: Forms