Howdy
I've been searching around the forums and documentation for a while but am still a bit lost about this. I've got a form which I want to validate server-side by using my own php function.
There's the "php" method in the RequiredFields class: http://api.silverstripe.org/2.4/forms/validators/RequiredFields.html - but I can't find any example of how this would work in the wild.
On the most basic level I'm looking for an example of how to get something like the code to work. This is where a value from a TextField is sent to a function which then returns a message and either does or doesn't validate the field.
$fields = new FieldSet(
new TextField('Number', 'Enter a Number', '' )
);
function ValidateNumber($Number){
if($Number == 10){
$Message = "You have entered the right number";
$Validate = true;
} else {
$Message = "You have entered the wrong number, try again";
$Validate = false;
}
}
Can someone please show me an example of how this would work inside the sapphire framework?
Cheers
Tama