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
This commit is contained in:
Ingo Schommer 2007-09-16 02:31:06 +00:00
parent d17251a311
commit e63c16fcff
2 changed files with 5 additions and 0 deletions

View File

@ -384,6 +384,8 @@ class NewsletterAdmin extends LeftAndMain {
$fields = $email->getCMSFields($this); $fields = $email->getCMSFields($this);
$fields->push($idField = new HiddenField("ID")); $fields->push($idField = new HiddenField("ID"));
$idField->setValue($myId); $idField->setValue($myId);
$fields->push($ParentidField = new HiddenField("ParentID"));
$ParentidField->setValue($email->ParentID);
$fields->push($typeField = new HiddenField("Type")); $fields->push($typeField = new HiddenField("Type"));
$typeField->setValue('Newsletter'); $typeField->setValue('Newsletter');
//$fields->push(new HiddenField("executeForm", "", "EditForm") ); //$fields->push(new HiddenField("executeForm", "", "EditForm") );

View File

@ -300,6 +300,9 @@ AddForm.prototype = {
// create a new node and add it to the site tree // create a new node and add it to the site tree
if( type == 'draft' ) { 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 ); $('sitetree').addDraftNode('New draft newsletter', parentID, $('Form_EditForm_ID').value );
} else { } else {
$('sitetree').addTypeNode('New newsletter type', $('Form_EditForm_ID').value ); $('sitetree').addTypeNode('New newsletter type', $('Form_EditForm_ID').value );