Update only current record for many_many relations

Fixes #48 but needs more testing. I only checked that it works for one case!
This commit is contained in:
Jyrki Lilja 2014-04-04 11:09:05 +03:00
parent 3851012b4b
commit 128737d12a

View File

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