Merge pull request #54 from jyrkij/fix-48

Update only current record for many_many relations
This commit is contained in:
Andrew Short 2014-06-13 11:43:50 +10:00
commit 1a521a3ce0

View File

@ -278,9 +278,17 @@ class GridFieldOrderableRows extends RequestHandler implements
if($list instanceof ManyManyList) { if($list instanceof ManyManyList) {
$extra = $list->getExtraFields(); $extra = $list->getExtraFields();
$key = $list->getLocalKey(); $key = $list->getLocalKey();
$foreignKey = $list->getForeignKey();
$foreignID = $list->getForeignID();
if(array_key_exists($this->getSortField(), $extra)) { if(array_key_exists($this->getSortField(), $extra)) {
return sprintf('"%s" %s', $key, $value); return sprintf(
'"%s" %s AND "%s" = %d',
$key,
$value,
$foreignKey,
$foreignID
);
} }
} }