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