created unlink routine

record can now be unlinked for the related page
This commit is contained in:
colymba 2012-08-15 21:16:41 +03:00
parent 2f778a4214
commit 471a1c1331
2 changed files with 19 additions and 1 deletions

View File

@ -37,7 +37,9 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
function getColumnMetadata($gridField, $columnName)
{
return array('title' => null);
if($columnName == 'BulkSelect') {
return array('title' => 'Select');
}
}
/* // GridField_ColumnProvider */

View File

@ -65,7 +65,23 @@ class GridFieldBulkManager_Request extends RequestHandler {
public function unlink(SS_HTTPRequest $request)
{
$recordList = $this->getPOSTRecordList($request);
$recordClass = $this->gridField->list->dataClass;
$recordForeignKey = $this->gridField->list->foreignKey;
//$recordForeignID = $this->gridField->list->foreignID;
$result = array();
foreach ( $recordList as $id )
{
$record = DataObject::get_by_id($recordClass, $id);
$res = $record->setField($recordForeignKey, 0);
$record->write();
array_push($result, array($id => $res));
}
$response = new SS_HTTPResponse(Convert::raw2json(array($result)));
$response->addHeader('Content-Type', 'text/plain');
return $response;
}
public function delete(SS_HTTPRequest $request)