This is an example validator for a data object... when you have this then it is called on each save this "checks" the values in the form before saving and can raise validation errors / messages next to specific form fields by name...
class ObjectA extends DataObject {
static $db = array(
"Name" => "Varchar",
);
function getCMSValidator() {
return new ObjectA_Validator();
}
function getValidator() {
return new ObjectA_Validator();
}
}
class ObjectA_Validator extends RequiredFields {
function php($data) {
$bRet = parent::php($data);
if (ObjectB::get()->filter('OtherName',$data['Name']))
$this->validationError('Name','ObjectB exists with that name',"required");
return count($this->getErrors());
}
}