mirror of
https://github.com/UndefinedOffset/SortableGridField.git
synced 2024-10-22 17:05:38 +02:00
Better handling of many_many relationship sorting
This commit is contained in:
parent
d075e856bc
commit
b10961873c
@ -107,6 +107,7 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
|
|
||||||
$className=$gridField->getModelClass();
|
$className=$gridField->getModelClass();
|
||||||
$ownerClass=$gridField->Form->Controller()->class;
|
$ownerClass=$gridField->Form->Controller()->class;
|
||||||
|
$controllerID=$gridField->Form->Controller()->ID;
|
||||||
|
|
||||||
$many_many=GridFieldSortableObject::is_sortable_many_many($className);
|
$many_many=GridFieldSortableObject::is_sortable_many_many($className);
|
||||||
if($many_many) {
|
if($many_many) {
|
||||||
@ -131,7 +132,7 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
for($sort=0;$sort<count($data['Items']);$sort++) {
|
for($sort=0;$sort<count($data['Items']);$sort++) {
|
||||||
$id=intval($data['Items'][$sort]);
|
$id=intval($data['Items'][$sort]);
|
||||||
if($many_many) {
|
if($many_many) {
|
||||||
DB::query("UPDATE \"$table\" SET \"SortOrder\" = $sort WHERE \"{$className}ID\" = $id");
|
DB::query("UPDATE \"$table\" SET \"SortOrder\" = $sort WHERE \"{$className}ID\" = $id AND \"{$ownerClass}ID\" = $controllerID");
|
||||||
}else {
|
}else {
|
||||||
$obj=DataObject::get_by_id($className, $id);
|
$obj=DataObject::get_by_id($className, $id);
|
||||||
$obj->SortOrder=$sort;
|
$obj->SortOrder=$sort;
|
||||||
|
Loading…
Reference in New Issue
Block a user