Project

General

Profile

Actions

Bug #102209

open

f:form Fields use old values after ForwardResponse

Added by Jonas Götze about 1 year ago. Updated 4 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2023-10-19
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues 2 (1 open1 closed)

Related to TYPO3 Core - Story #100955: Fluid form submitted successful... but i see the "old" data.Closed2023-06-04

Actions
Related to TYPO3 Core - Bug #97707: Fluid forms return old valuesNew2022-05-29

Actions
Actions

Also available in: Atom PDF