mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
Merge pull request #75 from open-sausages/pull/4/better-validate
This commit is contained in:
commit
c5191b5f78
@ -47,7 +47,7 @@ class Company extends DataObject
|
||||
'Name'=>'Varchar(255)',
|
||||
'Category'=>'Varchar(255)',
|
||||
'Revenue'=>'Float',
|
||||
'CEO'=>'Varchar(255)',
|
||||
'CEO'=>'Varchar(255)'
|
||||
);
|
||||
|
||||
private static $has_one = array(
|
||||
@ -102,13 +102,13 @@ class Company extends DataObject
|
||||
|
||||
public function validate()
|
||||
{
|
||||
if (!$this->Title) {
|
||||
$result = new ValidationResult();
|
||||
$result->addError('Title is required');
|
||||
return $result;
|
||||
} else {
|
||||
return parent::validate();
|
||||
$result = parent::validate();
|
||||
|
||||
if (!$this->Name) {
|
||||
$result->addFieldError('Name', 'Name is required');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function DynamicProperty()
|
||||
|
Loading…
Reference in New Issue
Block a user