Merge 0cf1cf147d
into 2cc9a999f9
This commit is contained in:
commit
5cabd5c4d8
|
@ -261,12 +261,22 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
|||
$recordClass = $this->gridField->list->dataClass;
|
||||
$recordForeignKey = $this->gridField->list->foreignKey;
|
||||
$recordForeignID = $this->gridField->list->foreignID;
|
||||
|
||||
$isManyMany = ($this->gridField->list instanceof ManyManyList);
|
||||
|
||||
$record = Object::create($recordClass);
|
||||
$record->setField($recordForeignKey, $recordForeignID);
|
||||
|
||||
if(!$isManyMany) {
|
||||
$record->setField($recordForeignKey, $recordForeignID);
|
||||
}
|
||||
|
||||
$record->write();
|
||||
|
||||
if($isManyMany) {
|
||||
$this->gridField->list->add($record->ID);
|
||||
}
|
||||
|
||||
$upload = new Upload();
|
||||
$upload = new Upload();
|
||||
$tmpfile = $request->postVar('BulkImageUploadField');
|
||||
|
||||
// Check if the file has been uploaded into the temporary storage.
|
||||
|
|
|
@ -187,20 +187,12 @@ 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));
|
||||
|
||||
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