• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Yet another validation question

#11
[eluser]danoph[/eluser]
Oh, I see. Hmm, I haven't usually dealt with sending data to a different controller and keeping validation data. If I do send the data to another controller, I just load the view. If the URL submitted has all the segments you need, it should load the view with all the right validation information.

The problem with redirecting is it refreshes the browser and deletes all POST variables and validation data.

#12
[eluser]charlieD[/eluser]
It sounds to me like the email methods should be in an 'email' model, so that you can use it in whatever controller you're in. Otherwise, you could put it in a library.

However, the other option is to use flashdata, which I've recently started using with the Native Session class and have found incredibly useful. You need to use the Native Session class in place of the default CodeIgniter one, but it's really easy to do.

http://codeigniter.com/wiki/Native_session/

Then you can:

Code:
$this->load->helper('url');
$this->load->library('session');

//If validation fails:
$this->session->set_flashdata('errMessage', 'Validation failed error message');
redirect('newprofile_url');

And on the profile page, you can get the message with:
Code:
if ($this->session->flashdata('errMessage')) echo $this->session->flashdata('errMessage');

#13
[eluser]Michael Wales[/eluser]
The Session library from the SVN now includes flash data (as well as ID regeneration).


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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