APC Action Applications - Home Page

Frequently Asked Questions v2

 

You can create your own usr_validate.php3 with a user validation function in it (sorry at this point there can only be one for an apc-aa installation, we'll fix that later, if you need it to validate multiple fields you can make it switch based on the field name).

Here is a sample validation function. If the file include/usr_validate.php3 is present it will be included automatically.


<?PHP
// ----- Sample code -------
// returns new value for the field.
// or just return $value;
function usr_validate( $varname, $showname, $value, $err, $f, $fields)
// $varname -- name of variable
// $showname - name of variable in the page.
// $value - value of the input field.
// $err - validated or not.
// Standard way:
// $err["$varname"] = MsgErr(L_ERR_IN." $inputName");
// $f - I DON"T KNOW... please read admin/itemedit.php3
// you can get all the info about the field. include name.
// $field - - all the fields
{
if (!$value) // no value set in the input field
return "Hey! It is working."; // set default value of the field
else if ($value == "stupid") { // if value is "stupid"
// set error
$err["$varname"] = MsgErr(L_ERR_IN." $showname".". Do not use the word.");
return "fool"; // return error, and change value to "fool".
}
else
return $value; // same value. no change.
}
?>

Last Edit: Aug 17 2011

<aafaq id=1720> ~ToDo: 1720 How do I create my own validation function </aafaq> 

This FAQ interface was developed by Jason at Commons.ca

APC: Internet and ICTs for social justice and development APC ActionApps is a free software content management system initiated by the Association for Progressive Communications (APC)
APC - Internet and ICTs for social justice and development