From e63c16fcff0a16968c84f6363d3aabdfb54d958f Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 16 Sep 2007 02:31:06 +0000 Subject: [PATCH] elofgren: BUGFIX: If no selection is made in the left tree, and a draft is added, parentID won't be set, so don't rely on it being set in Javascript and instead add a hidden ParentID field that is returned by PHP and use that so it is alway set correctly. This solves a bug where Newsletter drafts will be added, but not show up in the left tree (because of a Javascript error), if no selection has been made. (merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@42059 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/NewsletterAdmin.php | 2 ++ javascript/NewsletterAdmin_left.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/code/NewsletterAdmin.php b/code/NewsletterAdmin.php index fb1ae909..6a7e38f9 100755 --- a/code/NewsletterAdmin.php +++ b/code/NewsletterAdmin.php @@ -384,6 +384,8 @@ class NewsletterAdmin extends LeftAndMain { $fields = $email->getCMSFields($this); $fields->push($idField = new HiddenField("ID")); $idField->setValue($myId); + $fields->push($ParentidField = new HiddenField("ParentID")); + $ParentidField->setValue($email->ParentID); $fields->push($typeField = new HiddenField("Type")); $typeField->setValue('Newsletter'); //$fields->push(new HiddenField("executeForm", "", "EditForm") ); diff --git a/javascript/NewsletterAdmin_left.js b/javascript/NewsletterAdmin_left.js index 23dad899..32bdc624 100755 --- a/javascript/NewsletterAdmin_left.js +++ b/javascript/NewsletterAdmin_left.js @@ -300,6 +300,9 @@ AddForm.prototype = { // create a new node and add it to the site tree if( type == 'draft' ) { + // BUGFIX: If no selection is made in the left tree, and a draft is added, parentID won't be set, + // so we need to use the value from the Draft edit form. + parentID = $('Form_EditForm_ParentID').value; $('sitetree').addDraftNode('New draft newsletter', parentID, $('Form_EditForm_ID').value ); } else { $('sitetree').addTypeNode('New newsletter type', $('Form_EditForm_ID').value );