Welcome Guest, Not a member yet? Register   Sign In
Multi page forms, sessions and validation
#1

[eluser]Unknown[/eluser]
Hi all,
I'm trying to build a multi page form, and I save the form data in the session after each page is submitted. The final submit would insert to a database.

Now, the form pages also have 'back' buttons, and I'd like to have the form prefilled in that case. How do I do this while also prefilling the form during validation errors?

I tried to do it this way:
In the controller I have
Code:
if ($fields = $this->session->userdata('form1')) {
    foreach ($fields as $key => $value) {
        $this->validation->$key = $value; //looks ugly but I thought it would work.
    }
}
and in the view I have normal code like this:
Code:
<th>field description</th>
<td>&lt;?=form_input(array(
   'name' => 'myfield',
   'size' => '20',
   'value' => $this->validation->myfield));?&gt;
</td>

But it doesn't work. $this->validation->myfield appears to get unset somewhere. Although I checked to make sure it was set in the controller.

What am I missing? Is there a better way to prefill a form for both validation and session?
#2

[eluser]Darren Inwood[/eluser]
Hi there,

I've posted a 'fix' for the problem you're having:
http://ellislab.com/forums/viewthread/61874/

HTH!
--
Darren
#3

[eluser]Unknown[/eluser]
Thanks, that was exactly what I needed Smile




Theme © iAndrew 2016 - Forum software by © MyBB