From b75479a2b66e85ecc3f2df8dabaf89bdb9f3eb3b Mon Sep 17 00:00:00 2001 From: Nick Lamprecht Date: Tue, 31 Jan 2023 19:16:54 +0100 Subject: [PATCH] FIX Validate Category / Tag Titles Closes #695 --- src/Model/BlogCategory.php | 11 +++++++++++ src/Model/BlogTag.php | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Model/BlogCategory.php b/src/Model/BlogCategory.php index ae69c7de1..78ac26477 100644 --- a/src/Model/BlogCategory.php +++ b/src/Model/BlogCategory.php @@ -55,6 +55,17 @@ class BlogCategory extends DataObject implements CategorisationObject 'BlogPosts' => BlogPost::class, ]; + public function validate() + { + $result = parent::validate(); + + if(empty($this->Title)) { + $result->addError(_t(__CLASS__ . '.TitleNotEmpty', 'Title must not be empty')); + } + + return $result; + } + /** * {@inheritdoc} */ diff --git a/src/Model/BlogTag.php b/src/Model/BlogTag.php index 4180f67da..f8b509dcc 100644 --- a/src/Model/BlogTag.php +++ b/src/Model/BlogTag.php @@ -55,6 +55,17 @@ class BlogTag extends DataObject implements CategorisationObject 'BlogPosts' => BlogPost::class ]; + public function validate() + { + $result = parent::validate(); + + if(empty($this->Title)) { + $result->addError(_t(__CLASS__ . '.TitleNotEmpty', 'Title must not be empty')); + } + + return $result; + } + /** * {@inheritdoc} */