[TYPO3-mvc] Persistene problem with new objects from form inputs

Robert Böttner robert at boettner.it
Tue Dec 22 16:25:00 CET 2009


Hi Michael

try this:

	/**
	 * Adds a new album to repository
	 *
	 * @param Tx_Yag_Domain_Model_Album $newAlbum  New album to add
	 * @return string  The rendered create action
	 */
	public function createAction(Tx_Yag_Domain_Model_Album 			
         $newAlbum, Tx_Yag_Domain_Model_Gallery $gallery = NULL) {
		$this->albumRepository->add($newAlbum);
		if ($gallery != NULL) {
			$gallery->addAlbum($newAlbum);
		}

$persistenceManager = t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager');
/* @var $persistenceManager Tx_Extbase_Persistence_Manager */
$persistenceManager->persistAll();

		$this->flashMessages->add('Your new album was
                 created.');
		$this->redirect('index','Album', NULL, array('album' =>
                 $newAlbum, 'gallery' => $gallery));
	}

Cheers
Robert


More information about the TYPO3-project-typo3v4mvc mailing list