Welcome Guest, Not a member yet? Register   Sign In
repopulate from session?
#11

[eluser]shreder[/eluser]
Again, thanks for the reply.
I'm sorry if I wasn't clear, I'm not looking for a way to pass data to the view, I know how to do that.

What I'm looking for is how to save the data entered and have a back (or previous) button that the user can click and he goes back to the previous step and still have all the data he entered earlier saved in the fields...

Thanks
#12

[eluser]slowgary[/eluser]
Doesn't the browser do that for you anyways though? I still like the JavaScript approach, as there are other benefits. With the session method, the user needs to scroll down to the form for each step. You can use a page anchor...
Code:
<form action='page.php#form'>
But sometimes (if the connection is slow, or the page is heavy) the page will load and sit at the top for a seconds or two before it 'pops' down to the page anchor. If the user scrolls during that time period, the scrollby amount gets added to the pageY and the user ends up in the wrong place. On a busy design I can see how a user (especially non tech-savvy ones) could not realize they have more of a form to fill out.

I'm all for the easiest UI possible. In an ideal situation, you could not only separate your steps into a JavaScripted interface, but verify the form fields via ajax onchange and report errors on the fly. That would provide the highest usability.
#13

[eluser]xwero[/eluser]
shreder why do you think sessions are easier? The snippet i added is all the code you need to make it work.

The only thing that could stop you from using it is when the forms contain too much data, then the method becomes expensive, bandwidthwise.
#14

[eluser]Colin Williams[/eluser]
I think the issue is being way over-complicated. Your view is responsible for spitting out the form and its controls. The controller is going to prep the data. So, like I showed above, you can set the initial values to whatever is available in the session. If nothing is available in the session, you get blank form controls. If there is $_POST data available, the set_value() function uses it instead of the session data, which may or may not be available.

Quote:If I’m not mistaken then it’s 4K Per session, right?
What if I set a session for EACH field? I doubt it will pass the 4K limit

There is not a session per field. Sessions refer to periods of use by one user/client. You use a session id to append data to particular sessions. Like I said earlier, use database session storage and you don't have to worry about the limit because only the ID is stored.

Quote:What I’m looking for is how to save the data entered and have a back (or previous) button that the user can click and he goes back to the previous step and still have all the data he entered earlier saved in the fields

Maybe you haven't read the Session class documentation in the user guide? You will use the session class to store the data collected along the way. Then, on a successful completion, you can unset the session data. Sketch out a diagram to help yourself along.




Theme © iAndrew 2016 - Forum software by © MyBB