From 8cee1ab4de109c89105189c2c20449ec889eb85a Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 19 Feb 2008 00:15:44 +0000 Subject: [PATCH] Merged revisions 43365 via svnmerge from svn://svn.silverstripe.com/silverstripe/modules/cms/branches/2.1.0-rc3oriwave2 ........ r43365 | hsmith | 2007-10-12 15:33:57 +1300 (Fri, 12 Oct 2007) | 1 line Changed call to ViewableData::castingHelperPair to fix sort not being set by getNewItem ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@49766 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSMain.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/CMSMain.php b/code/CMSMain.php index 56927ded..a066a911 100644 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -441,7 +441,9 @@ JS; $newItem->ClassName = $className; $newItem->ParentID = $parentID; - if($newItem->fieldExists('Sort')) { + // DataObject::fieldExists only checks the current class, not the hierarchy + // This allows the CMS to set the correct sort value + if($newItem->castingHelperPair('Sort')) { $newItem->Sort = DB::query("SELECT MAX(Sort) FROM SiteTree WHERE ParentID = '" . Convert::raw2sql($parentID) . "'")->value() + 1; }