+ Passing data from page to page +
+ ++ You may want to use or display data a user has entered over a few screens. The kit automatically stores all data entered, so you can show it later. +
+ ++ To clear the data (for example at the end of a user research session) click the "Clear data" link in the footer. +
+ ++ You can see an example here. +
+ ++ The code for the example is in this folder in the prototype kit: +
+ +++ ++ /docs/views/examples/pass-data + ++
How to use
+ +The kit stores data from inputs using the name attribute of the input.
+ +For example, if you have this input:
+ +++ ++ <input name="first-name"> + ++
You can show what the user entered later on like this:
+ +++ + ++ <p>{%raw%}{{ data['first-name'] }}{%endraw%}</p> + ++
+ Clearing data +
+ ++ To clear the data (for example at the end of a user research session) click the "Clear data" link in the footer. +
+ ++ Showing answers in inputs +
+ ++ If a user goes back to a page where they entered data, they would expect to see the answer they gave. +
+ +For a text input:
+++ ++ <input name="first-name" value="{%raw%}{{ data['first-name'] }}{%endraw%}"> + ++
For a radio or checkbox input you need to use the 'checked' function:
+++ ++ <input type="radio" name="over-18" value="yes" {%raw%}{{ checked('over-18','yes') }}{%endraw%}> + ++
Advanced features
+ ++ Using the data on the server +
+ +You can access the data on the server in a route, for example for an input with name="first-name":
+ +++ ++ var firstName = req.session.data['first-name'] + ++
+ Ignoring inputs +
+ +To prevent an input being stored, use an underscore at the start of the name.
+ +++ ++ <input name="_secret"> + ++