Beispiel #1
0
 public function validate()
 {
     // the lower-case version of the code must be unique
     if (empty($this->code)) {
         $this->setError('A code is required');
     } elseif (!empty($this->code) && ($existing = $this->codeExists($this->code))) {
         if (empty($this->id) || $this->id != $existing->id) {
             $this->setError('This code already exists');
         }
     }
     return parent::validate();
 }
Beispiel #2
0
 public function validate()
 {
     if (empty($this->title)) {
         $this->setError('Title is required');
     }
     if (empty($this->slug)) {
         $this->setError('A slug is required');
     }
     if ($existing = $this->slugExists($this->slug)) {
         if (empty($this->id) || $existing->id != $this->id) {
             // An item with this slug already exists. Slugs must be unique.
             $this->slug = $this->generateSlug();
         }
     }
     return parent::validate();
 }
 public function validate()
 {
     return parent::validate();
 }