Permalink
Browse files

Prevent calling fixSortColumn() and saveGridSort() with UnsavedDataLists

  • Loading branch information...
UndefinedOffset committed Feb 8, 2013
1 parent fef2529 commit 7f2a6dc525cef27d0a9ad557cd70836ee6e94015
Showing with 13 additions and 0 deletions.
  1. +13 −0 code/forms/GridFieldSortableRows.php
@@ -20,6 +20,10 @@ public function __construct($sortColumn) {
* @return Array Map where the keys are fragment names and the values are pieces of HTML to add to these fragments.
*/
public function getHTMLFragments($gridField) {
+ if(class_exists('UnsavedRelationList') && $dataList instanceof UnsavedRelationList) {
+ return array();
+ }
+
$state = $gridField->State->GridFieldSortableRows;
if(!is_bool($state->sortableToggle)) {
$state->sortableToggle = false;
@@ -113,6 +117,10 @@ public function getManipulatedData(GridField $gridField, SS_List $dataList) {
* @param SS_List $dataList Data List of items to be checked
*/
protected function fixSortColumn($gridField, SS_List $dataList) {
+ if(class_exists('UnsavedRelationList') && $dataList instanceof UnsavedRelationList) {
+ return;
+ }
+
$list=clone $dataList;
$list=$list->alterDataQuery(function($query, SS_List $tmplist) {
$query->limit(array());
@@ -238,6 +246,11 @@ public function handleAction(GridField $gridField, $actionName, $arguments, $dat
* @param Array $data Data submitted in the request
*/
protected function saveGridRowSort(GridField $gridField, $data) {
+ if(class_exists('UnsavedRelationList') && $dataList instanceof UnsavedRelationList) {
+ user_error('Cannot sort an UnsavedRelationList', E_USER_ERROR);
+ return;
+ }
+
if(!singleton($gridField->getModelClass())->canEdit()){
throw new ValidationException(_t('GridFieldSortableRows.EditPermissionsFailure', "No edit permissions"),0);
}

0 comments on commit 7f2a6dc

Please sign in to comment.