From 0771001c0bd0c89b40097416253bddcbce215e9b Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 19 Aug 2008 10:08:52 +0000 Subject: [PATCH] Added ModelAdmin_ClassController::getResultColumns() method, so that it can be overloaded Fixed action handlers on fields of ResultsForm (notably the TableListField) by adding querystring arguments to the Link() of the form. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@61066 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/ModelAdmin.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/code/ModelAdmin.php b/code/ModelAdmin.php index 975ad164..61bea8b3 100644 --- a/code/ModelAdmin.php +++ b/code/ModelAdmin.php @@ -468,20 +468,29 @@ class ModelAdmin_CollectionController extends Controller { return $context->getQuery($searchCriteria); } + function getResultColumns($searchCriteria) { + $model = singleton($this->modelClass); + $summaryFields = $model->summaryFields(); + + $resultAssembly = $searchCriteria['ResultAssembly']; + foreach($summaryFields as $fieldname=>$label){ + if(!$resultAssembly[$fieldname]){ + unset($summaryFields[$fieldname]); + } + } + + return $summaryFields; + } + /** * Shows results from the "search" action in a TableListField. * * @return Form */ function ResultsForm($searchCriteria) { - $model = singleton($this->modelClass); - $summaryFields = $model->summaryFields(); - $resultAssembly = $_REQUEST['ResultAssembly']; - foreach($summaryFields as $fieldname=>$label){ - if(!$resultAssembly[$fieldname]){ - unset($summaryFields[$fieldname]); - } - } + if($searchCriteria instanceof HTTPRequest) $searchCriteria = $searchCriteria->getVars(); + $summaryFields = $this->getResultColumns($searchCriteria); + $tf = new TableListField( $this->modelClass, $this->modelClass, @@ -515,6 +524,8 @@ class ModelAdmin_CollectionController extends Controller { unset($filteredParams['action_search']); $tf->setExtraLinkParams($filteredParams); + $form->setFormAction($this->Link() . '/ResultsForm?' . http_build_query($searchCriteria)); + return $form; }