Skip to content

Commit

Permalink
ENHANCEMENT Setting default group title in Group->populateDefaults()
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92564 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed Nov 21, 2009
1 parent b1300f7 commit 58cfa9f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion security/Group.php
Expand Up @@ -180,6 +180,15 @@ function fieldLabels($includerelations = true) {
return $labels;
}

function populateDefaults() {
parent::populateDefaults();

if(!$this->Title) $this->Title = sprintf(
_t('GROUP.NEWITEM',"New %s"),
singleton($this->class)->i18n_singular_name()
);
}

/**
* Add a member to a group.
*
Expand Down Expand Up @@ -313,7 +322,7 @@ public function setCode($val){

function onBeforeWrite() {
parent::onBeforeWrite();

if(stripos($this->Code, 'new-') === 0) {
$this->setCode($this->Title);
}
Expand Down

0 comments on commit 58cfa9f

Please sign in to comment.