BUGFIX Setting default $groups in MemberTableField::AddForm() in addition to MemberTableField_Popup::__construct() - this was broken by r99777

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@99993 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-02-26 01:15:30 +00:00 committed by Sam Minnee
parent f94ad4f988
commit 55520f1523

View File

@ -306,6 +306,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
@ -408,6 +420,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);