FIX #3, FIX #11 should work with all RelationList

This commit is contained in:
colymba 2013-03-04 11:44:53 +02:00
parent 7546bd08c0
commit bc8f2bda59
2 changed files with 5 additions and 18 deletions

View File

@ -274,15 +274,13 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
public function upload(SS_HTTPRequest $request) public function upload(SS_HTTPRequest $request)
{ {
$recordClass = $this->gridField->list->dataClass; $recordClass = $this->gridField->list->dataClass;
$recordForeignKey = $this->gridField->list->foreignKey;
$recordForeignID = $this->gridField->list->foreignID;
$record = Object::create($recordClass); $record = Object::create($recordClass);
$record->setField($recordForeignKey, $recordForeignID);
// passes the current gridfield-instance to a call-back method on the new object // passes the current gridfield-instance to a call-back method on the new object
$record->extend("onBulkImageUpload", $this->gridField); $record->extend("onBulkImageUpload", $this->gridField);
$record->write(); $record->write();
$this->gridField->list->add($record->ID);
$upload = new Upload(); $upload = new Upload();
$tmpfile = $request->postVar('BulkImageUploadField'); $tmpfile = $request->postVar('BulkImageUploadField');

View File

@ -187,20 +187,9 @@ class GridFieldBulkManager_Request extends RequestHandler {
public function unlink(SS_HTTPRequest $request) public function unlink(SS_HTTPRequest $request)
{ {
$recordList = $this->getPOSTRecordList($request); $recordList = $this->getPOSTRecordList($request);
$recordClass = $this->gridField->list->dataClass; $this->gridField->list->removeMany($recordList);
$recordForeignKey = $this->gridField->list->foreignKey;
//$recordForeignID = $this->gridField->list->foreignID;
$result = array();
foreach ( $recordList as $id ) $response = new SS_HTTPResponse(Convert::raw2json(array($recordList)));
{
$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'); $response->addHeader('Content-Type', 'text/plain');
return $response; return $response;
} }