[TYPO3-mvc] Add multiple models in a foreach loop
Matthias Zaunseder
zaunseder at glanzer-und-partner.de
Mon Aug 12 10:19:39 CEST 2013
Hello all,
I have a problem with Extbase and I hope you can help me out :)
I have a CSV upload field and I try to import the data in a foreach loop.
In the controller class is a uploadAction and there I loop over the
models in the CSV.
foreach($csvRows as $dealer) {
$newDealer = new Tx_Dealersearch_Domain_Model_Dealer();
$newDealer->setName($dealer['name']);
...
$this->dealerRepository->add($newDealer);
$this->flashMessageContainer->add($newDealer->getName() . ' saved.');
}
If I try to save 10 dealers, then after the upload, there are 10 times
the data of the last dealer in the database. And it's weird that all
data sets have a uid = 0 and pid = 0. The database looks like this after
the upload:
|uid|pid|name|...
|0 |0 |dealer nr. 10|
|0 |0 |dealer nr. 10|
... etc.
so the dealer nr. 1, 2, 3, etc. are missing...
Is it completely wrong to iterate in a controller and to instantiate the
models yourself? Or should I change something in the configuration?
Thanks!
Matthias
--
Matthias Zaunseder
Webentwickler
G + P Glanzer + Partner Werbeagentur GmbH
Paracelsusstr. 26, 70599 Stuttgart
Tel: +49 (0)711 1673-365, Fax: +49 (0)711 4569390
zaunseder at glanzer-und-partner.de
www.glanzer-und-partner.de
Geschäftsführer: Peter Chvojka, Mathias Muthny
Sitz: Stuttgart, Amtsgericht Stuttgart, HRB 11330
More information about the TYPO3-project-typo3v4mvc
mailing list