Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

How to keep form datas while going to another form ?

Hello,

I have a form (form number 1) with a select option field (categories).

I fill some input fields and I need to choose a category, but it doesn't exist. So I need to add a new category, but I don't want to go out of the form. There is an "add" button just beside the select option field.

By clicking on the "add" button, I go to another form (form number 2) to create a new category.

I know how to use a modal window and ajax to create a new category and then automatically select the corresponding option in the form number 1.

But is it possible to keep the form number 1 data in memory while going to the other form without a modal window and ajax ?

Thank you for your help ;).

Vincent

0 likes
5 replies
jlrdw's avatar
jlrdw
Best Answer
Level 75

Normally you would use session. If ajax pass an array.

2 likes
vincent15000's avatar

@jlrdw I've not had time to test yet but it seems to be exactly what I need.

I will add the content of the fields in the session and then the user will navigate to another page. When he returns to the initial form, I will fill the fields with the data from the session if the session exists. I had never worked with sessions, but it seems to be very useful.

I tell you as soon as I have tested.

Please or to participate in this conversation.