mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #384 from mateusz/uploadfield-derivedclasses
BUGFIX: include derived classes for attaching in the UploadField.
This commit is contained in:
commit
0e9bdc17c9
@ -915,16 +915,18 @@ class UploadField_SelectHandler extends RequestHandler {
|
|||||||
$config->addComponent(new GridFieldDataColumns());
|
$config->addComponent(new GridFieldDataColumns());
|
||||||
$config->addComponent(new GridFieldPaginator(10));
|
$config->addComponent(new GridFieldPaginator(10));
|
||||||
|
|
||||||
// Create the data source for the list of files within the current directory.
|
// If relation is to be autoset, we need to make sure we only list compatible objects.
|
||||||
$files = DataList::create('File')->filter('ParentID', $folderID);
|
$baseClass = null;
|
||||||
|
|
||||||
// If relation is to be autoset, make sure only objects from related class are listed.
|
|
||||||
if ($this->parent->relationAutoSetting) {
|
if ($this->parent->relationAutoSetting) {
|
||||||
if ($relationClass = $this->parent->getRelationAutosetClass()) {
|
$baseClass = $this->parent->getRelationAutosetClass();
|
||||||
$files->filter('ClassName', $relationClass);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// By default we can attach anything that is a file, or derives from file.
|
||||||
|
if (!$baseClass) $baseClass = 'File';
|
||||||
|
|
||||||
|
// Create the data source for the list of files within the current directory.
|
||||||
|
$files = DataList::create($baseClass)->filter('ParentID', $folderID);
|
||||||
|
|
||||||
$fileField = new GridField('Files', false, $files, $config);
|
$fileField = new GridField('Files', false, $files, $config);
|
||||||
$fileField->setAttribute('data-selectable', true);
|
$fileField->setAttribute('data-selectable', true);
|
||||||
if($this->parent->getConfig('allowedMaxFileNumber') > 1) $fileField->setAttribute('data-multiselect', true);
|
if($this->parent->getConfig('allowedMaxFileNumber') > 1) $fileField->setAttribute('data-multiselect', true);
|
||||||
|
Loading…
Reference in New Issue
Block a user