CodeIgniter Forums

Full Version: how to pass form validation result objects from 1st controller to 2nd controller?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum


class Form extends CI_Controller {

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


$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)

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!

El Forum

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