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
This commit is contained in:
Sam Minnee 2008-08-19 10:08:52 +00:00
parent e2eee05b83
commit 0771001c0b

View File

@ -468,20 +468,29 @@ class ModelAdmin_CollectionController extends Controller {
return $context->getQuery($searchCriteria); 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. * Shows results from the "search" action in a TableListField.
* *
* @return Form * @return Form
*/ */
function ResultsForm($searchCriteria) { function ResultsForm($searchCriteria) {
$model = singleton($this->modelClass); if($searchCriteria instanceof HTTPRequest) $searchCriteria = $searchCriteria->getVars();
$summaryFields = $model->summaryFields(); $summaryFields = $this->getResultColumns($searchCriteria);
$resultAssembly = $_REQUEST['ResultAssembly'];
foreach($summaryFields as $fieldname=>$label){
if(!$resultAssembly[$fieldname]){
unset($summaryFields[$fieldname]);
}
}
$tf = new TableListField( $tf = new TableListField(
$this->modelClass, $this->modelClass,
$this->modelClass, $this->modelClass,
@ -515,6 +524,8 @@ class ModelAdmin_CollectionController extends Controller {
unset($filteredParams['action_search']); unset($filteredParams['action_search']);
$tf->setExtraLinkParams($filteredParams); $tf->setExtraLinkParams($filteredParams);
$form->setFormAction($this->Link() . '/ResultsForm?' . http_build_query($searchCriteria));
return $form; return $form;
} }