From eea6cf978d6f0463d4082a7c8606622bab8dd728 Mon Sep 17 00:00:00 2001 From: Normann Lou Date: Tue, 26 Aug 2008 01:54:53 +0000 Subject: [PATCH] The searchCriteria will be added as $_GET to the form action, rather than that TableListField's extraLinkParams git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@61511 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/ModelAdmin.php | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/code/ModelAdmin.php b/code/ModelAdmin.php index f8330adb..be2541fe 100644 --- a/code/ModelAdmin.php +++ b/code/ModelAdmin.php @@ -473,13 +473,13 @@ class ModelAdmin_CollectionController extends Controller { $summaryFields = $model->summaryFields(); $resultAssembly = $searchCriteria['ResultAssembly']; - foreach($summaryFields as $fieldname=>$label){ - if(!$resultAssembly[$fieldname]){ - unset($summaryFields[$fieldname]); - } + if(!is_array($resultAssembly)) { + $explodedAssembly = split(' *, *', $resultAssembly); + $resultAssembly = array(); + foreach($explodedAssembly as $item) $resultAssembly[$item] = true; } - - return $summaryFields; + + return array_intersect_key($summaryFields, $resultAssembly); } /** @@ -516,16 +516,12 @@ class ModelAdmin_CollectionController extends Controller { new FieldSet() ); - // HACK to preserve search parameters on TableField - // ajax actions like pagination - $filteredParams = $this->request->getVars(); - unset($filteredParams['ctf']); - unset($filteredParams['url']); - unset($filteredParams['action_search']); - $tf->setExtraLinkParams($filteredParams); - - $form->setFormAction($this->Link() . '/ResultsForm?' . http_build_query($searchCriteria)); - + // Include the search criteria on the results form URL, but not dodgy variables like those below + $filteredCriteria = $searchCriteria; + unset($filteredCriteria['ctf']); + unset($filteredCriteria['url']); + unset($filteredCriteria['action_search']); + $form->setFormAction($this->Link() . '/ResultsForm?' . http_build_query($filteredCriteria)); return $form; }