Welcome Guest, Not a member yet? Register   Sign In
need example form repopulation with session data

(form validation library CI 1.7.0)

Hi, I want to repopulate a form, using the Form Validation library, with session data (if the data exists). I was thinking about something like this:

if ($this->form_validation->run() == FALSE)
            //Not OK OR validation hasn't run yet

            // Check for session data

                // Repopulate form with session data


                // Blank form - initial state
                $data = array();

            // OK - Do stuff with validated input data

Is there a method I can use to repopulate from fields?
Something like:

$this->form_validation->fieldname = "some value";
$this->form_validation->set_value('fieldname','some value');

(both don't work)

Look at the form validation class for re-populating the form

<title>My Form</title>

<?php echo validation_errors(); ?>

<?php echo form_open('form'); ?>

&lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?&gt;" size="50" /&gt;

&lt;input type="text" name="password" value="&lt;?php echo set_value('password'); ?&gt;" size="50" /&gt;

<h5>Password Confirm</h5>
&lt;input type="text" name="passconf" value="&lt;?php echo set_value('passconf'); ?&gt;" size="50" /&gt;

<h5>Email Address</h5>
&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?&gt;" size="50" /&gt;

<div>&lt;input type="submit" value="Submit" /&gt;&lt;/div>



Theme © iAndrew 2016 - Forum software by © MyBB