Refresh on redirect

Hello, i am new to slim v4 and try to build a web app following @odan 's ebook.
My problem:
I have a form created by FormAction class, form data is sent via POST method to SubmitAction class
which writes form-data to a file and shall return back to the initial FormAction class which should read the file and display the updated data.
Things work as expected BUT when i redirect to FormAction class using

return $response->withStatus(302)->withHeader('Location', /myform);

the form seems to be cached and does not reload data as expected. When i reload using F5 the updated data is shown.
So how can i refresh on redirect (or disable caching in that case)?

How do you handle the form? Do you have any type of form validation? Do you use ajax or not?
The server does not cache the form data. What do you expect after the form has been submitted and saved, and what do you expect when you have an input / validation error?
Can you please add more details and screenshots?

sorry to respond so late…

this is a “rough sketch” of project, so there is no ajax involved, no form validation middleware.

To see the behavior please visit http://dienstplan.galak.online/wuensche. You will find a more or less complex form for a duty roster with names and dropdown fields to select “d” for duty or “f” for free.

When clicking the submit button, form data gets stored (confirmed working) by “WishSubmitAction” which redirects back to the calling form. I expect to see the form data updated but this does not happen. But when i hit F5 to reload, i see the updated from data.

Feel free to check the sources in my github repo

Thx for any hint

Why do you destroy the session for each request to the whishlist page? I try would remove this first.

as i said: i thought there was some kind of caching going on.
Meanwhile I found my mistake. I put too much logic in the __construct function of my worker class. Moving the “loading stuff” to its proper function fixed the behavior…

Thanks for your help!

1 Like