Skip to content

Commit

Permalink
Merge pull request #75 from open-sausages/pull/4/better-validate
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensby committed Sep 18, 2020
2 parents 11c4dd8 + 4d2d362 commit c5191b5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions code/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -102,13 +102,13 @@ public function getCMSFields()

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()
Expand Down

0 comments on commit c5191b5

Please sign in to comment.