[TYPO3-mvc] Creating Multiple Objects with a single view

Nathan Lenz typo3 at k9tfk.com
Mon Jan 4 23:24:50 CET 2010


Sebastian Kurfürst wrote:
> Hey,
> 
> I just looked at the property mapper, and at first glance I'd say that
> it supports arrays of objects as well. So it could be a Fluid issue. Try
> to build the form yourself (using standard HTML), and add
> @dontverifyrequesthash inside your controller.
> 
> It'd be great if you could report your findings here! If that already
> works, then we'd only need to change the ViewHelpers a bit.
> 
> Greets,
> Sebastian

It works when I add this to the form:

<h3>Ingredient Groups</h3>
<label for="ingredientGroups[0][name]">Name: </label>
<f:form.textbox name="ingredientGroups[0][name]" /><br />

<label for="ingredientGroups[1][name]">Name: </label>
<f:form.textbox name="ingredientGroups[1][name]" /><br />
		
Then making the Action contain a second parameter:

/**
 * Create a new recipe.
 *
 * @dontverifyrequesthash
 * @param Tx_Organicrecipe_Domain_Model_Recipe $newRecipe
 * @param array $ingredientGroups Sets of Ingredients grouped by name
 * @return void
 */
public function createAction(Tx_Organicrecipe_Domain_Model_Recipe
$newRecipe, array $ingredientGroups) {

	$this->propertyMapper->map(array('ingredientGroups'),array('ingredientGroups'=>$ingredientGroups),$newRecipe);
	
	$this->recipeRepository->add($newRecipe);
	$this->flashMessages->add('Your new recipe was created.');
	$this->redirect('index');
	
}


However, when I try "mapAndValidate" it complains that my 5th parameter
doesn't implement the
Tx_Extbase_Validation_Validator_ObjectValidatorInterface, which it
doesn't because it doesn't exist.


So this tells me that you are correct, the mapper does in fact work with
 array, ArrayObject and Tx_Extbase_Persistence_ObjectStorage.



More information about the TYPO3-project-typo3v4mvc mailing list