Bug #102209
openf:form Fields use old values after ForwardResponse
0%
Description
Hi,
when using an object in a f:form Field and this object gets replaced after submitting the form by a forwardResponse which forwards to the form again, the form still uses the previous object.
I try to explain my scenario as I think this makes it easier to understand.
I have two actions:
- newAction
- createAction
The newAction has an optional Argument $previousLog.
The create Action also has an argument $previousLog. $previousLog is a persisted Record.
The createAction creates a new $log Record (linked to the previous) and does some checks. If these fail, it persists the $log record and returns a forwardReponse to the newAction, passing the $log record as $previousLog using $forwardResponse->withArguments()
In the Template new.html there is a form field like this<f:form.hidden name="previousLog" value="{previousLog}" />
(could also be f:form.textfield)
After the first forward happened, this field is correct and looks like this:<input type="hidden" name="tx_myext_myplugin[previousLog][__identity]" value="1">
Now if there is another forward after submitting the form the hidden input still has the same value it had first time(1). No matter how many times you repeat the form submit.
Though if one does<f:debug>{previousLog}</f:debug>
or just output {previousLog}
directly the value is correct (2, then 3 and so on).
I had a look at
\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::getValueFromSubmittedFormData
There a value from getLastSubmittedFormData() is used preferably and only if this is not available the value-Attribute of the viewhelper is used. This function uses $this->renderingContext->getRequest()->getOriginalRequest()->getArguments()
So I guess this does not take the forwardResponse into Account.
But I could not dig deeper until now, as I already spent a lot of time in finding out what was going on here.
It works fine with a redirect instead of forward.
Tested on TYPO3 11.