mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
#2310 MemberTableField Popup breaks after saving
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@50947 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
48bb2a55bb
commit
6511df5ece
@ -362,12 +362,14 @@ class MemberTableField_Popup extends ComplexTableField_Popup {
|
|||||||
Requirements::javascript('cms/javascript/MemberTableField_popup.js');
|
Requirements::javascript('cms/javascript/MemberTableField_popup.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same behaviour as parent class, but adds the member to the passed GroupID.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function saveComplexTableField() {
|
function saveComplexTableField() {
|
||||||
$id = (isset($_REQUEST['ctf']['childID'])) ? Convert::raw2sql($_REQUEST['ctf']['childID']) : false;
|
if(isset($_REQUEST['ctf']['childID']) && is_numeric($_REQUEST['ctf']['childID'])) {
|
||||||
|
$childObject = DataObject::get_by_id($this->sourceClass, $_REQUEST['ctf']['childID']);
|
||||||
if (is_numeric($id)) {
|
|
||||||
$childObject = DataObject::get_by_id($this->sourceClass, $id);
|
|
||||||
} else {
|
} else {
|
||||||
$childObject = new $this->sourceClass();
|
$childObject = new $this->sourceClass();
|
||||||
$this->fields->removeByName('ID');
|
$this->fields->removeByName('ID');
|
||||||
@ -375,13 +377,19 @@ class MemberTableField_Popup extends ComplexTableField_Popup {
|
|||||||
|
|
||||||
$this->saveInto($childObject);
|
$this->saveInto($childObject);
|
||||||
$childObject->write();
|
$childObject->write();
|
||||||
|
|
||||||
// add member to current group
|
// custom behaviour for MemberTableField: add member to current group
|
||||||
$childObject->Groups()->add($_REQUEST['GroupID']);
|
$childObject->Groups()->add($_REQUEST['GroupID']);
|
||||||
|
|
||||||
// if ajax-call in an iframe, close window by javascript, else redirect to referrer
|
// if ajax-call in an iframe, update window
|
||||||
if(!Director::is_ajax()) {
|
if(Director::is_ajax()) {
|
||||||
Director::redirect(substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'],'?')));
|
// Newly saved objects need their ID reflected in the reloaded form to avoid double saving
|
||||||
|
$form = $this->controller->DetailForm($childObject->ID);
|
||||||
|
$form->loadDataFrom($childObject);
|
||||||
|
FormResponse::update_dom_id($form->FormName(), $form->formHtmlContent(), true, 'update');
|
||||||
|
return FormResponse::respond();
|
||||||
|
} else {
|
||||||
|
Director::redirectBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user