Methods for any properties that require user input should always be the same name as the property key you have specified when adding a product. So, assume you have added
a product with two properties and they both require user input.
So, here the methods should be named 'Param' & 'Key'. Example:
function Param($input) {
}
function Key($input) {
}
Inside these functions is your validation. So, lets say that the value of 'Key' can only be numeric, you might do:
function Key($input) {
return (ctype_digit($input) ? true : false);
}
This uses the ctype function. You might also do:
function Key($input) {
if (is_numeric($input)) {
return true;
} else {
return false;
}
}
Regular expressions can also be used:
function Key($input) {
if (preg_match('/^\d+$/', $input)) {
return true;
} else {
return false;
}
}
Prefix 'cube_' to property keys that begin with a number. So, lets say your property key is '123key', for input validation use the following function name:
function cube_123key($input) {
xxxx
}
More examples below.