From ab5ea4c0f6f48551880130b83ee34337e9484fac Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 28 Aug 2008 22:57:18 +0000 Subject: [PATCH] Show result-assembly columns so that you read down the column instead of zigzagging git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@61721 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/ModelAdmin.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/code/ModelAdmin.php b/code/ModelAdmin.php index 74efc87d..f99c1433 100644 --- a/code/ModelAdmin.php +++ b/code/ModelAdmin.php @@ -430,7 +430,22 @@ class ModelAdmin_CollectionController extends Controller { if($source) foreach ($source as $fieldName => $label){ $value[] = $fieldName; } - $checkboxes = new CheckboxSetField("ResultAssembly", false, $source, $value); + + // Reorder the source so that you read items down the column and then across + $columnisedSource = array(); + $keys = array_keys($source); + $midPoint = ceil(sizeof($source)/2); + for($i=0;$i<$midPoint;$i++) { + $key1 = $keys[$i]; + $columnisedSource[$key1] = $source[$key1]; + // If there are an odd number of items, the last item will be unset + if(isset($keys[$i+$midPoint])) { + $key2 = $keys[$i+$midPoint]; + $columnisedSource[$key2] = $source[$key2]; + } + } + + $checkboxes = new CheckboxSetField("ResultAssembly", false, $columnisedSource, $value); $field = new CompositeField( new LiteralField(