From 95a1c51ca65d27bdca4adfd269508de05991bd32 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 14 Mar 2012 17:20:25 +0100 Subject: [PATCH] ENHANCEMENT Demo'ing model validation through Company->validate() --- code/Company.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/Company.php b/code/Company.php index 7e832e2..f160501 100644 --- a/code/Company.php +++ b/code/Company.php @@ -29,7 +29,13 @@ class Company extends DataObject { public static $summary_fields = array('Name', 'Category', 'Revenue', 'CEO'); + function validate() { + if(!$this->Title) { + return new ValidationResult(false, 'Title is required'); + } else { + return parent::validate(); } + } public function requireDefaultRecords() {