mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
ENHANCEMENT: added option to truncate (clear) database table before importing a new CSV file with CSVBulkerLoader and ModelAdmin.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@85709 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
ada0084506
commit
cbaa5840c3
@ -451,6 +451,7 @@ class ModelAdmin_CollectionController extends Controller {
|
||||
))->renderWith('ModelAdmin_ImportSpec');
|
||||
|
||||
$fields->push(new LiteralField("SpecFor{$modelName}", $specHTML));
|
||||
$fields->push(new CheckboxField('EmptyBeforeImport', 'Clear Database before import', true));
|
||||
|
||||
$actions = new FieldSet(
|
||||
new FormAction('import', _t('ModelAdmin.IMPORT', 'Import from CSV'))
|
||||
@ -495,6 +496,11 @@ class ModelAdmin_CollectionController extends Controller {
|
||||
}
|
||||
|
||||
$results = $loader->load($_FILES['_CsvFile']['tmp_name']);
|
||||
if (!empty($data['EmptyBeforeImport']) && $data['EmptyBeforeImport']) { //clear database before import
|
||||
$results = $loader->load($_FILES['_CsvFile']['tmp_name'], '512M', true);
|
||||
} else { //normal import without clearing
|
||||
$results = $loader->load($_FILES['_CsvFile']['tmp_name']);
|
||||
}
|
||||
|
||||
$message = '';
|
||||
if($results->CreatedCount()) $message .= sprintf(
|
||||
|
Loading…
Reference in New Issue
Block a user