[TYPO3-mvc] Fluid: Complex forms best practice

Sebastian Fischer sebastian at fischer.im
Thu Jul 9 11:02:29 CEST 2009


Sebastian KurfŸürst schrieb:
> Hi Nikolas,
> 
>> The most obvious solution for such a scenario is to forgo  all fluid 
>> magic
>> (field population, validation etc).
>> This means put everything to a huge data container 
>> (tx_foo[data][xyz])  pass
>> it over  to the controller and  process it manually.
> Nooo, that's not nice at all :-)
> 
> 
>> One that came to my mind was to create a non-persistent meta 
>> "registration
>> object"
>> but I am not sure yet it this is a passable solution. Any comments on 
>> this?
> I guess this would work, but is not that nice...
> 
> Did you try the following:
> 
> Inside your fluid template:
> 
> <f:form action="create" name="newUser" object="{newUser}">
>     <!-- bind an object to the form -->
> 
> <f:form.textbox property="name" />
>     <!-- have some fields with magic :-) -->
> 
> <f:form.textbox name="age" />
>     <!-- a field which should not belong to newUser -->
> 
> </f:form>
> 
> then, inside your controller, try the following:
> 
> /**
>  * @param ...User $newUser
>  * @param integer $age The age of the person
> public function createAction($newUser, $age) {
> ....
> }
> 
> This *should* work, though I did not test it right now.
> 
> - Does it sound intuitive to you?
> - Could you please test it and give feedback if it works? If not, we 
> need to fix that :-)
> 
> Greets,
> Sebastian

Hi Sebastian,

though its an solution for one field, its no solution for many fields. 
Imagine 20 additonal parameter of the method.

Thinking of feedbackforms i dont have a solution. Unless you want to 
store every feedback in the backend there could be lots of fields, and i 
dont think its an good idea to have a methode like

public function sendmailAction($param1, $param2....) {

maybe its a solution to use func_get_args, then again extbase doesnt 
recognize them in the reflection and is not able to fill them in.

Greetings,
Sebastian


More information about the TYPO3-project-typo3v4mvc mailing list