Reputation: 701
I have this problem:
I have 3 templates:
Search_user
Show_user
Edit_user
Whit the search_user I'm getting the name value with the post method, then I'll search the data in the db, save the data in an array called user and then pass the array to the Show_user template.
In the Show_user template I show the data with {{ user[0] }}, {{ user[1] }}...{{ user[7] }}
, under this data I have a button that bring me to the Edit_user
template.
But in the Edit_user
template I don't know how to pass the previous data, I don't know hot to export data with the post method or any other methods.
A walk around could be <input type="text" name="surname" value="user[0]" required>
but I don't want to show the textbox in the Show_user
template.
Upvotes: 0
Views: 38
Reputation: 19641
You don't need to pass any data except some kind of user identifier (a number or a user name) to fetch the user back from the database when needed.
It can be done in multiple ways:
/user/edit/<user-id>
)type=hidden
)In any case you just need to get that piece of information (from the URL endpoint, from the session, from the form data...), use it to fetch the user from the database, then pass the user to the edit template.
If you're using a web framework just read the docs, this is a trivial use case that we'll be very likely well documented.
If you need more details, please, share a few code fragments.
Upvotes: 1