From 65aa49d5640087eb3ce67ccadeb6515769bc1924 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 4 Oct 2010 05:47:08 +0000 Subject: [PATCH] BUGFIX Setting default $groups in MemberTableField::AddForm() in addition to MemberTableField_Popup::__construct() - this was broken by r99777 (from r99993) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@111617 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/MemberTableField.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/code/MemberTableField.php b/code/MemberTableField.php index d749fbcd..67e32cf2 100755 --- a/code/MemberTableField.php +++ b/code/MemberTableField.php @@ -326,6 +326,18 @@ class MemberTableField extends ComplexTableField { ) ); } + + function AddForm() { + $form = parent::AddForm(); + + // Set default groups - also implemented in MemberTableField_Popup::__construct() + if($this->group) { + $groupsField = $form->Fields()->dataFieldByName('Groups'); + if($groupsField) $groupsField->setValue($this->group->ID); + } + + return $form; + } /** * Same behaviour as parent class, but adds the @@ -428,6 +440,7 @@ class MemberTableField_Popup extends ComplexTableField_Popup { function __construct($controller, $name, $fields, $validator, $readonly, $dataObject) { $group = ($controller instanceof MemberTableField) ? $controller->getGroup() : $controller->getParent()->getGroup(); + // Set default groups - also implemented in AddForm() if($group) { $groupsField = $fields->dataFieldByName('Groups'); if($groupsField) $groupsField->setValue($group->ID);