[TYPO3-mvc] How to send Tx_Extbase_Persistence_ObjectStorage to a Controller action?

Franz Koch typo3.RemoveForMessage at elements-net.de
Tue Feb 8 11:44:07 CET 2011


Hi Simon,

> i have a list of objects and i want to select some with a checkbox to
> edit those entries in another view.
>
> How do I need to format my template and my action so that i can handle
> that?
>
> what i have is the following as a starting point:
>
> <f:form method="post" controller="Project" action="edit" name="project">
> <input type="checkbox" value="1" name="tx_myextension_pi1[projects]">
> <input type="checkbox" value="2" name="tx_myextension_pi1[projects]">
> <input type="checkbox" value="3" name="tx_myextension_pi1[projects]">
> <input type="checkbox" value="4" name="tx_myextension_pi1[projects]">
> <input type="checkbox" value="5" name="tx_myextension_pi1[projects]">
> </f:form>
>
> <input type="checkbox" value="5" name="tx_myextension_pi1[projects][]">
>
> also doesn't help.

Actually I'm not sure if this is going to work, but I never tried it. 
First thing is of course that you have to change the field names to 
reflect a array, otherwise only one of the selected values will be 
submitted. Second thing would be to probably submit the UID as 
__identity, so give the following a try:

<input type="checkbox" value="5" 
name="tx_myextension_pi1[projects][][__identity]">

But as I said - not sure if this is going to work that way. What will 
definitely work would be one of this cases:

- change the argument type to array and fetch the according objects form 
the repository
- use a little wrapper object as argument type and assign the checkbox 
values to a property of it

/**
  * ...
  */
public function editAction(Tx_ExtKey_Domain_Model_ProjectDemand 
$projectDemand) {
	$this->view->assign('projects', $projectDemand->getProjects());
}

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list