From 7db5f7b2e9a8dde8f911d509ce8fd36a1ae9ad0d Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 27 Nov 2008 00:21:31 +0000 Subject: [PATCH] BUGFIX Fixed importer not working because of i18n_singular_name(), just use the class name of the model instead git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@66799 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/ModelAdmin.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/code/ModelAdmin.php b/code/ModelAdmin.php index b175e1cf..434c6fd3 100644 --- a/code/ModelAdmin.php +++ b/code/ModelAdmin.php @@ -351,9 +351,7 @@ class ModelAdmin_CollectionController extends Controller { */ public function ImportForm() { $modelName = $this->modelClass; - $importers = $this->parentController->getModelImporters(); - if(!$importers || !isset($importers[$modelName])) return false; $fields = new FieldSet( @@ -374,7 +372,7 @@ class ModelAdmin_CollectionController extends Controller { $specRelations->push(new ArrayData(array('Name' => $name, 'Description' => $desc))); } $specHTML = $this->customise(array( - 'ModelName' => Convert::raw2att(str_replace(' ', '', singleton($modelName)->i18n_singular_name())), + 'ModelName' => Convert::raw2att($modelName), 'Fields' => $specFields, 'Relations' => $specRelations, ))->renderWith('ModelAdmin_ImportSpec'); @@ -406,11 +404,19 @@ class ModelAdmin_CollectionController extends Controller { * @param unknown_type $request */ function import($data, $form, $request) { - $modelName = singleton($data['ClassName'])->i18n_singular_name(); + $modelName = $data['ClassName']; $importers = $this->parentController->getModelImporters(); $importerClass = $importers[$modelName]; $loader = new $importerClass($data['ClassName']); + + // File wasn't properly uploaded, show a reminder to the user + if(empty($_FILES['_CsvFile']['tmp_name'])) { + $form->sessionMessage(_t('ModelAdmin.NOCSVFILE', 'Please browse for a CSV file to import'), 'good'); + Director::redirectBack(); + return false; + } + $results = $loader->load($_FILES['_CsvFile']['tmp_name']); $message = '';