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
This commit is contained in:
Sam Minnee 2010-10-04 05:47:08 +00:00
parent a1cbf0cddf
commit 65aa49d564

View File

@ -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);