CodeIgniter Forums
how to pass form validation result objects from 1st controller to 2nd controller? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: how to pass form validation result objects from 1st controller to 2nd controller? (/showthread.php?tid=43795)



how to pass form validation result objects from 1st controller to 2nd controller? - El Forum - 07-23-2011

[eluser]Alpha[/eluser]
<?php

class Form extends CI_Controller {

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

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

$this->form_validation->set_rules('username', 'Username', 'required');
$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');
}
}
}
?>

at the view myform.php the errors will be displayed using <?php echo validation_errors(); ?> but what my setup is that from the above Form controller i need to pass the form_validation object/results to the 2nd controller and i need the 2nd controller to know what happened/results from the previous controller through the passed object so that it can also print <?php echo validation_errors(); ?> when needed or for whatever purpose. tnx!


how to pass form validation result objects from 1st controller to 2nd controller? - El Forum - 07-24-2011

[eluser]toopay[/eluser]
You can send the $_POST value from controller 1 to controller 2(which have validation rule runs), or... use session to store error variable...