From eefc4ffc0687b807097899bebaec1bad9c704cc4 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Tue, 30 Oct 2007 03:17:18 +0000 Subject: [PATCH] #1562 - Group codes don't appear to be generated upon creation of group git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@44002 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- security/Group.php | 8 ++++++++ 1 file changed, 8 insertions(+) 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 { }