diff --git a/security/Group.php b/security/Group.php index e48c5f0de..d6fe0d3ca 100644 --- a/security/Group.php +++ b/security/Group.php @@ -159,6 +159,14 @@ class Group extends DataObject { public function setCode($val){ $this->setField("Code",SiteTree::generateURLSegment($val)); } + + function onBeforeWrite() { + parent::onBeforeWrite(); + + if(stripos($this->Code, 'new-') === 0) { + $this->setCode($this->Title); + } + } } class Group_Unsecure extends Group { }