[TYPO3-mvc] access form fields inside ViewHelper widget

typo3 at litedesigns.nl typo3 at litedesigns.nl
Fri Apr 6 10:33:21 CEST 2012


Hi List,

I'm trying to write a ViewHelper widget for a file upload which works
together with a FileUploadService i've created.

Once the file is uploaded, but the form is not valid yet, i want to store
the filename in a hidden field to keep a reference to the uploaded file.
But i'm having trouble accessing form fields in my ViewHelper.

My ViewHelper is added inside my form, so the ViewHelper is not the
complete form itself, just some formfields. The form is an 'aggregate'
form with multiple objects.

<f:form method="post" controller="MyController" action="myAction"
id="newObjectAggregate" name="newObjectAggregate"
object="{newObjectAggregate}" enctype="multipart/form-data">

<f:form.textfield property="objectA.foo" value="{objectA.foo}" />
<f:form.textfield property="objectB.bar" value="{objectB.bar}" />
...
<lta:widget.fileUpload file="{myFile}" />
...
</f:form>

And in my ViewHelper template (simplified):
<f:form.hidden name="tempFile" value="{tempFile}"/>
<f:form.upload name="file" property="file" />


In my ViewHelper and ViewHelper controller i can access all form fields of
objectA and objectB, but i can't seem to get a hold of my hidden field
'tempFile'. The only way i can access the tempFile value is by directly
looking in the $_POST array.

I have tried finding the submitted 'tempFile' value in:
$this->templateVariableContainer
$this->viewHelperVariableContainer
$this->arguments
$this->controllerContext->getRequest()->getArguments()
in my ViewHelper and ViewHelper controller, but i can't find it anywhere.

My ViewHelper controller reads the $_FILES and uses my FileUploadService
to upload the file and then sets the tempFile value in my ViewHelper
template in the hidden field, but when the form is submitted again i loose
the tempFile value.

Could anyone give me a hint where i should look for this post value?

Kind regards,
Ti




More information about the TYPO3-project-typo3v4mvc mailing list