FIX: Forgot to include the classname that can be derived from the config-option 'imageFieldName'...

This commit is contained in:
s-m 2013-02-02 18:26:48 +01:00
parent 381d6a28ad
commit c26fae6aaa
1 changed files with 11 additions and 3 deletions

View File

@ -120,15 +120,23 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
}
/**
* Returns the classname of the first has_one image-relation of the managed DataObject
* Returns the classname of the first has_one image-relation of the managed DataObject or the
* classname of the given fieldname
*
* @return string
*/
private function getDefaultRecordImageClass()
private function getRecordImageClass()
{
$recordClass = $this->gridField->list->dataClass;
$recordHasOneFields = Config::inst()->get($recordClass, 'has_one', Config::INHERITED);
$fieldName = $this->component->getConfig('imageFieldName');
if($fieldName != null)
{
// filter out ID at the end:
$fieldName = substr($fieldName, 0, -2);
return $recordHasOneFields[$fieldName];
}
foreach($recordHasOneFields as $field => $type)
{
if($type == 'Image' || is_subclass_of($type, 'Image'))
@ -306,7 +314,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
// Process the uploaded file
if (!$return['error']) {
$fileObject = Object::create($this->getDefaultRecordImageClass());
$fileObject = Object::create($this->getRecordImageClass());
// Get the uploaded file into a new file object.
try {