#102209f:form Fields use old values after ForwardResponse
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 name="previousLog" value="{previousLog}"></f:form><input type="hidden" name="tx_myext_myplugin[previousLog][__identity]" value="1">@
(could also be f:form.textfield)
After the first forward happened, this field is correct and looks like this:
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>{previousLog}@ directly the value is correct (2, then 3 and so on).
or just output
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.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch
- Commit message
-
[BUGFIX] f:form Fields use old values after ForwardResponse Resolves: #102209 Releases: main