From f93b782e9428927a9985fc0a0cac2f93b31b2a5e Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Fri, 12 Dec 2008 09:58:05 +0000 Subject: [PATCH] BUGFIX Fixed HasManyComplexTableField/ManyManyComplexTableField issue with source items which broke from changes in r66080. Thanks hamish! git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@68628 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/HasManyComplexTableField.php | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/forms/HasManyComplexTableField.php b/forms/HasManyComplexTableField.php index 997d84ca1..90d3a8f91 100644 --- a/forms/HasManyComplexTableField.php +++ b/forms/HasManyComplexTableField.php @@ -68,33 +68,24 @@ class HasManyComplexTableField extends ComplexTableField { } function sourceItems() { - if($this->sourceItems) - return $this->sourceItems; + if($this->sourceItems) return $this->sourceItems; $limitClause = ''; - if(isset($_REQUEST[ 'ctf' ][ $this->Name() ][ 'start' ]) && is_numeric($_REQUEST[ 'ctf' ][ $this->Name() ][ 'start' ])) + if(isset($_REQUEST['ctf'][$this->Name()]['start']) && is_numeric($_REQUEST['ctf'][$this->Name()]['start'])) { $limitClause = $_REQUEST[ 'ctf' ][ $this->Name() ][ 'start' ] . ", $this->pageSize"; - else + } else { $limitClause = "0, $this->pageSize"; + } $dataQuery = $this->getQuery($limitClause); $records = $dataQuery->execute(); $items = new DataObjectSet(); - foreach($records as $record) { - if(! get_class($record)) - $record = new DataObject($record); - $items->push($record); - } + + $sourceClass = $this->sourceClass; + $dataobject = new $sourceClass(); + $items = $dataobject->buildDataObjectSet($records, 'DataObjectSet'); - $dataQuery = $this->getQuery(); - $records = $dataQuery->execute(); - $unpagedItems = new DataObjectSet(); - foreach($records as $record) { - if(! get_class($record)) - $record = new DataObject($record); - $unpagedItems->push($record); - } - $this->unpagedSourceItems = $unpagedItems; + $this->unpagedSourceItems = $dataobject->buildDataObjectSet($records, 'DataObjectSet'); $this->totalCount = ($this->unpagedSourceItems) ? $this->unpagedSourceItems->TotalItems() : null;