Welcome Guest, Not a member yet? Register   Sign In
validation loop and back button, and wont wear a wig !!
#1

[eluser]tim1965[/eluser]
Hi

I have a set of registration forms that are working correctly with validation, each form validates correctly and redirects. The data for each form is stored in a temp table and then at the end of the process there is a master save that moves all the data to the live tables.
I want to add a back/previous form button that will allow the user to go backto the previous form. This will essentiallt involve looking up the data from the previous form and populatin gthe relevant fields.
I have found an approach to this using
//HTML
<input type="submit" value="Save" name="submit_action" />
<input type="submit" value="Save and Finish" name="submit_action" />

//PHP
$action = $this->input->post('submit_action');

if($action == 'Save') {
...
} else if($action == 'Save and Finish') {
...
}
This would essentially allow me to hit the back button to take me back to the previous form calling the db query and then populating the form using set_value's default.
So my problem is trying to integrate this funcionality on the source form i.e. one with the back button.
The structure of my controller is essentially as per the user guide, i wont post the actual controllers due to size (but the structure is essentially the same).
class Form extends Controller {

function index()
{
$this->load->helper(array('form', 'url'));

$this->load->library('form_validation');

$this->form_validation->set_rules('username', 'Username', 'callback_username_check');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');

if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$this->load->view('formsuccess');
}
}

However i am struggling to get these to work together (bad day!!). As i cant work out where to place the submit functionality. I have tried this lots of different ways but essentially come back to validation run and form load need to come first, which gives me a problem grabbing the $_post submit value. Please help me save what little hair i have. Thanks.


Messages In This Thread
validation loop and back button, and wont wear a wig !! - by El Forum - 03-03-2009, 08:38 AM
validation loop and back button, and wont wear a wig !! - by El Forum - 03-03-2009, 10:27 AM
validation loop and back button, and wont wear a wig !! - by El Forum - 03-04-2009, 02:08 AM
validation loop and back button, and wont wear a wig !! - by El Forum - 03-04-2009, 06:14 AM
validation loop and back button, and wont wear a wig !! - by El Forum - 03-04-2009, 06:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB