[TYPO3-mvc] Working with Tx_Extbase_Persistence_ObjectStorage

Gernot Leitgab leitgab at gmail.com
Fri Aug 5 09:46:38 CEST 2011


I wrote an extension for feuser registration, therefore I extended from
Tx_Extbase_Domain_Model_FrontendUser. During registration it should be
possible to choose a usergroup. For testing purposes I loaded available
groups with the appropriate repository and generated a select-field with
it. In my final version selection should be possible with radio-fields.

Model (extended from Tx_Extbase_Domain_Model_FrontendUser, so
addUsergroup, removeUsergroup, etc. are available):
> [...]
> /**
>  * @var
Tx_Extbase_Persistence_ObjectStorage<Tx_Extbase_Domain_Model_FrontendUserGroup>
>  * @validate NotEmpty
>  */
> protected $usergroup;
> [...]

Controller:
> [...]
> /**
>  * This action shows the 'new' form for the frontend user.
>  *
>  * @param Tx_MyExt_Domain_Model_FrontendUser $newUser
>  * @dontvalidate $newUser
>  */
> public function newAction(Tx_MyExt_Domain_Model_FrontendUser $newUser
= null) {
> 	if ($newUser === null) {
> 		$newUser =
t3lib_div::makeInstance('Tx_MyExt_Domain_Model_FrontendUser');
> 	}
> 	
> 	$this->view->assign('newUser', $newUser);
> 	
> 	$this->frontendUserGroupRepository =
t3lib_div::makeInstance('Tx_Extbase_Domain_Repository_FrontendUserGroupRepository');
> 	$this->view->assign('usergroupArray',
$this->frontendUserGroupRepository->findAll());
> }
> [...]

Template:
> <f:form action="create" controller="User" name="newUser"
object="{newUser}" method="post">
> 	[...]
> 	<f:form.select name="usergroup" property="usergroup"
options="{usergroupArray}" optionValueField="uid"
optionLabelField="title" />
> 	[...]
> </f:form>

My problem is, that the selected usergroup is not stored in the
database. If validation fails, the submitted parameter is not set again
for this field, all other fields show the submitted parameters again.

Any idea how I can solve this problem?


More information about the TYPO3-project-typo3v4mvc mailing list