Hi!
I’m designing this app that basically lets you fill out checkboxes, multiple choices and inputs on the homepage. Then, once that’s done, the user can press a search button which takes him to another form that will present the results he got from whatever choices he selected on the homepage.
So basically, what I’m trying to do is have a ‘Back’ button on the results form/page that will let you go back to the homepage with the options that you had previously filled out still there. However, I can only seem to return to an empty homepage.
Is there any way to do this without having to manually store all data from the homepage form to the results form using openform?
I hope that makes sense.
Thanks
The short answer: use the hash routing from Anvil Extras (do a forum search on Hash Routing for details). It will cache the previous forms and handle the back button automatically.
The (only slightly) longer answer: you need to keep a reference to the original form around, instead of creating a new instance of it. With the reference to the original form, the checkboxes will still be the way they were. It’s avoiding creating a new instance of the previous form that will maintain the state of the form.
If you’re not going to use hash routing, then you have to keep that reference yourself. You can pass it to the new form you’re opening, so it can use it to reopen the previous form when appropriate.
4 Likes
Sounds good thanks a lot, I decided to simply keep a reference to the form filled out when I go from one form to another and it works perfectly.
Thanks again.
HI there, how do you keep a reference to the original form?
Pass the original form to the __init__
of the new form, and put it into a self.whatever
variable that you can use later.
2 Likes