• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to pass form validation result objects from 1st controller to 2nd controller?

#1
[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!

#2
[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...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.