mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Using sigular name for model import form rather than class name
This commit is contained in:
parent
791a846fbf
commit
13cec2ee81
@ -334,25 +334,28 @@ abstract class ModelAdmin extends LeftAndMain {
|
|||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
public function ImportForm() {
|
public function ImportForm() {
|
||||||
$modelName = $this->modelClass;
|
$modelSNG = singleton($this->modelClass);
|
||||||
|
$modelName = $modelSNG->i18n_singular_name();
|
||||||
// check if a import form should be generated
|
// check if a import form should be generated
|
||||||
if(!$this->showImportForm || (is_array($this->showImportForm) && !in_array($modelName,$this->showImportForm))) {
|
if(!$this->showImportForm ||
|
||||||
|
(is_array($this->showImportForm) && !in_array($this->modelClass, $this->showImportForm))
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$importers = $this->getModelImporters();
|
$importers = $this->getModelImporters();
|
||||||
if(!$importers || !isset($importers[$modelName])) return false;
|
if(!$importers || !isset($importers[$this->modelClass])) return false;
|
||||||
|
|
||||||
if(!singleton($modelName)->canCreate(Member::currentUser())) return false;
|
if(!$modelSNG->canCreate(Member::currentUser())) return false;
|
||||||
|
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
new HiddenField('ClassName', _t('ModelAdmin.CLASSTYPE'), $modelName),
|
new HiddenField('ClassName', _t('ModelAdmin.CLASSTYPE'), $this->modelClass),
|
||||||
new FileField('_CsvFile', false)
|
new FileField('_CsvFile', false)
|
||||||
);
|
);
|
||||||
|
|
||||||
// get HTML specification for each import (column names etc.)
|
// get HTML specification for each import (column names etc.)
|
||||||
$importerClass = $importers[$modelName];
|
$importerClass = $importers[$this->modelClass];
|
||||||
$importer = new $importerClass($modelName);
|
$importer = new $importerClass($this->modelClass);
|
||||||
$spec = $importer->getImportSpec();
|
$spec = $importer->getImportSpec();
|
||||||
$specFields = new ArrayList();
|
$specFields = new ArrayList();
|
||||||
foreach($spec['fields'] as $name => $desc) {
|
foreach($spec['fields'] as $name => $desc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user