Cleaned the code for the unlink method (Is recordList used anywhere? Still checking)
This commit is contained in:
parent
7ddad1fe4b
commit
0cf1cf147d
|
@ -187,25 +187,12 @@ class GridFieldBulkManager_Request extends RequestHandler {
|
|||
public function unlink(SS_HTTPRequest $request)
|
||||
{
|
||||
$recordList = $this->getPOSTRecordList($request);
|
||||
$result = array();
|
||||
|
||||
if($this->gridField->list instanceof HasManyList) {
|
||||
$recordClass = $this->gridField->list->dataClass;
|
||||
$recordForeignKey = $this->gridField->list->foreignKey;
|
||||
//$recordForeignID = $this->gridField->list->foreignID;
|
||||
|
||||
foreach ( $recordList as $id ) {
|
||||
$record = DataObject::get_by_id($recordClass, $id);
|
||||
$res = $record->setField($recordForeignKey, 0);
|
||||
$record->write();
|
||||
array_push($result, array($id => $res));
|
||||
}
|
||||
} else {
|
||||
$result = $recordList;
|
||||
if($this->gridField->list instanceof RelationList) {
|
||||
$this->gridField->list->removeMany($recordList);
|
||||
}
|
||||
|
||||
$response = new SS_HTTPResponse(Convert::raw2json(array($result)));
|
||||
$response = new SS_HTTPResponse(Convert::raw2json(array($recordList)));
|
||||
$response->addHeader('Content-Type', 'text/plain');
|
||||
return $response;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue