mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX properly setting $childID in form for newly created items to avoid duplicates after subsequent saving (the form reloaded without the ID connection)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.2.2@50940 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
3fa6d91992
commit
5abd33e58a
@ -253,12 +253,14 @@ JS;
|
|||||||
* <parentIDName>, Link back to the correct parent record (e.g. "parentID").
|
* <parentIDName>, Link back to the correct parent record (e.g. "parentID").
|
||||||
* parentClass, Link back to correct container-class (the parent-record might have many 'has-one'-relationships)
|
* parentClass, Link back to correct container-class (the parent-record might have many 'has-one'-relationships)
|
||||||
* CAUTION: "ID" in the DetailForm would be the "childID" in the overview table.
|
* CAUTION: "ID" in the DetailForm would be the "childID" in the overview table.
|
||||||
|
*
|
||||||
|
* @param int $childID
|
||||||
*/
|
*/
|
||||||
function DetailForm() {
|
function DetailForm($childID = null) {
|
||||||
|
|
||||||
// Get all the requests
|
// Get all the requests
|
||||||
$ID = isset($_REQUEST['ctf']['ID']) ? Convert::raw2xml($_REQUEST['ctf']['ID']) : null;
|
$ID = isset($_REQUEST['ctf']['ID']) ? Convert::raw2xml($_REQUEST['ctf']['ID']) : null;
|
||||||
$childID = isset($_REQUEST['ctf']['childID']) ? Convert::raw2xml($_REQUEST['ctf']['childID']) : null;
|
if(!isset($childID)) $childID = isset($_REQUEST['ctf']['childID']) ? Convert::raw2xml($_REQUEST['ctf']['childID']) : null;
|
||||||
$childClass = Convert::raw2xml($_REQUEST['fieldName']);
|
$childClass = Convert::raw2xml($_REQUEST['fieldName']);
|
||||||
$this->methodName = isset($_REQUEST['methodName']) ? $_REQUEST['methodName'] : null;
|
$this->methodName = isset($_REQUEST['methodName']) ? $_REQUEST['methodName'] : null;
|
||||||
|
|
||||||
@ -766,9 +768,10 @@ class ComplexTableField_Popup extends Form {
|
|||||||
$this->saveInto($childObject);
|
$this->saveInto($childObject);
|
||||||
$childObject->write();
|
$childObject->write();
|
||||||
|
|
||||||
|
// if ajax-call in an iframe, update window
|
||||||
if(Director::is_ajax()) {
|
if(Director::is_ajax()) {
|
||||||
// if ajax-call in an iframe, update window
|
// Newly saved objects need their ID reflected in the reloaded form to avoid double saving
|
||||||
$form = $this->controller->DetailForm();
|
$form = $this->controller->DetailForm($childObject->ID);
|
||||||
$form->loadDataFrom($childObject);
|
$form->loadDataFrom($childObject);
|
||||||
FormResponse::update_dom_id($form->FormName(), $form->formHtmlContent(), true, 'update');
|
FormResponse::update_dom_id($form->FormName(), $form->formHtmlContent(), true, 'update');
|
||||||
return FormResponse::respond();
|
return FormResponse::respond();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user