mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
created unlink routine
record can now be unlinked for the related page
This commit is contained in:
parent
2f778a4214
commit
471a1c1331
@ -37,7 +37,9 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||||||
|
|
||||||
function getColumnMetadata($gridField, $columnName)
|
function getColumnMetadata($gridField, $columnName)
|
||||||
{
|
{
|
||||||
return array('title' => null);
|
if($columnName == 'BulkSelect') {
|
||||||
|
return array('title' => 'Select');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* // GridField_ColumnProvider */
|
/* // GridField_ColumnProvider */
|
||||||
|
@ -65,7 +65,23 @@ class GridFieldBulkManager_Request extends RequestHandler {
|
|||||||
|
|
||||||
public function unlink(SS_HTTPRequest $request)
|
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)
|
public function delete(SS_HTTPRequest $request)
|
||||||
|
Loading…
Reference in New Issue
Block a user