Go back to previous form from current form

does anvil have a convenient built-in function to help me quickly go back to the previous form from current form?

I’m not aware of any built-in convenience functions to do this.

I do this by passing around parameters that tell my forms which form came before.

I’ll try to get a basic app together to show this if I can find the time tonight.

Good idea! please share me later, I also try it by myself.

@mch8418

Here’s one approach that uses the Material Design. Every time a new form opens I add a property to the tag attribute of the back button that keeps track of the previous page.

Others may have better ways of accomplishing this. I hope it helps.

clone:
https://anvil.works/build#clone:4HIJURNJM2VNVVUF=6LTEYJWBGIAHB2SMGNHOBMIW

the approach in the sample app only seems to work if there is a single path from form to form. What if several forms lead to single form, how can I keep track of which particular form I came from so I go back to that form?

A form is an object. Like any other object (dictionary, list, string, number, …), you can save its value into a variable. As long as that variable “lives”, so does the form, even if it is not currently being displayed.

So, just save the value, in some place (even an app-global variable) where it can be found later.

2 Likes

I have used the app global variable , mirroring the approach discussed here: