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

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

View File

@ -187,20 +187,9 @@ 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();
$this->gridField->list->removeMany($recordList);
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 = new SS_HTTPResponse(Convert::raw2json(array($recordList)));
$response->addHeader('Content-Type', 'text/plain');
return $response;
}