[TYPO3-mvc] Multiple Checkboxes for an object in a form

Christian Zenker christian.zenker at 599media.de
Tue Nov 9 12:21:00 CET 2010


Hi.

I'm trying to build a registration system for direct_mail. The task seems  
simple: records in tt_address need to be created, edited, and deleted.  
This works quite well this far.

But what is driving me almost crazy for the last hours is the selection of  
categories the user wants to receive. This should be done by checkboxes  
the user might tick if he wants to receive newsletters on a certain topic.  
Working with the "property"-parameter of the Form_CheckboxViewHelper seems  
not to be an option as it seems it is only capable of pre-checking ONE  
option and the user is only capable of UNchecking categories, as the  
domain object would only return an array with categories it is linked to.

So I decided to give the template an additional variable with all  
available categories and checking the selected ones through a custom  
viewHelper. It looks something like this:

<f:form name="address" method="post" controller="Address" action="create"  
object="{address}">

<!-- fields for all other fields -->

<f:for each="{categories}" as="category">
	<f:form.checkbox name="mailCategoriesAsArray[]" value="{category.uid}"  
checked="{x:customViewHelper(...)}" />
</f:for>
</f:form>

This sets an additional parameter $mailCategoriesAsArray in the create  
action. I have to assign it manually to the model but thats ok. BUT, it is  
not possible to select 2 or more categories as the HMAC will encounter an  
attack (probably as it does not expect an array).

I tried several approaches, but none of them seem to work. Has anybody  
done something similar before? How could I solve this issue?

Christian.


More information about the TYPO3-project-typo3v4mvc mailing list