[TYPO3-mvc] Cannot add objects from Controller, but from Backend

Frans van der Veen typo3 at dejuisteoplossing.nl
Tue Nov 12 14:59:51 CET 2013


Hi freetime coder,

Have you tried to add:
       $this->mapRepository->update($map);
in your ReportController::createAction, after you do:
       $map->addReport($newReport);
Appears to me it's missing.

Regards,

Frans

On 11/12/2013 01:19 AM, freetime coder wrote:
> Hi,
>
> I have been fighting with typo3 for weeks, mostly successful, but now I
> ran into something I have not been able to figure out. I am using
> version 6.1.5 and have created a rudimentary plugin base by using the
> Extension Builder. I created a map as aggregate root and a report m:n
> relation. Reports should mark spots on the map.
>
> First I created test reports in the backend and added the records
> manually to the map, but now I wrote frontend templates for creating,
> editing and deleting them. While the backend solution works the frontend
> controller methods only create the reports but adding them to the map
> does not work.
>
> So here is what I got:
> MapController -> list, show
> ReportController -> new, create, list, edit, delete
>
> and here are the used methods:
>
> ReportController;
>
> public function newAction(\myPackage\myExt\Domain\Model\Map $map,
> \myPackage\myExt\Domain\Model\Report $newReport = NULL) {
>      $this->view->assign('newReport', $newReport);
>      $this->view->assign('map', $map);
> }
>
> public function createAction(\myPackage\myExt\Domain\Model\Report
> $newReport, \myPackage\myExt\Domain\Model\Map $map) {
>      $this->reportRepository->add($newReport);
>      $map->addReport($newReport);
>      $this->redirect('update', 'Map', NULL, array('map' => $map));
> }
>
>
> MapController:
>
> public function updateAction(\myPackage\myExt\Domain\Model\Map $map) {
>      $this->mapRepository->update($map); //has to be done for
> persistence manager
>
>      $this->redirect('show', 'Map', NULL, array('map' => $map));
> }
>
>
> Everything runs without error, but the map does not get the new report.
> I have read that redirect calls the persistenceManager's persistAll, but
> I also tried to call it directly, which does not make a difference.
>
> Is there anything obvious I am missing?
>
> greetings and thanks for any info,
> freetimecoder
>



More information about the TYPO3-project-typo3v4mvc mailing list