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 #1

Updated by Jonas Götze about 1 year ago

quick "workaround": use
<f:form.select class="d-none" name="previousLog">
<option value="{previousLog.uid}"></option>
</f:form.select>

as replacement for the f:form.hidden element (.d-none = display:none). Maybe it helps someone.

Actions #2

Updated by Garvin Hicking 4 months ago

  • Category set to Extbase
Actions #3

Updated by Riccardo De Contardi 4 months ago

  • Related to Story #100955: Fluid form submitted successful... but i see the "old" data. added
Actions #4

Updated by Riccardo De Contardi 4 months ago

I report here the description of #100955 to keep track of it

Hello professionals,

I have a question of understanding and maybe this will result in an extension/modification.
In my extension a form is successfully submitted. After that I make a forward to the show action. So I can delegate the validationResults and other control commands (switch to the right tab) to the show action. So far so good. BUT: in the form the content of the "submitted Object" is still displayed.

I use the ViewHelper <f:form> in combination with the object attribute.

In the controller I reset the object after the successful submit:

$this->view->assign('myObject', new MyEntityObject());

When I write the template #{myObject.xyz}# I get ##. <- From this I conclude that everything is empty.

But in the textfield <f:textfield property="xyz"> it says "the old value"?

How do I get <f:form> to display the empty object? Am I doing something wrong? Is there another secret switch? Or is this a bug? Or is there something missing in the doc?

Thanks for reading and for helpful hints.
Clemens

Actions #5

Updated by Riccardo De Contardi 4 months ago

  • Related to Bug #97707: Fluid forms return old values added
Actions

Also available in: Atom PDF