CodeIgniter Forums
Validation with redirect? - 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: Validation with redirect? (/showthread.php?tid=5601)



Validation with redirect? - El Forum - 01-28-2008

[eluser]fakeempire[/eluser]
Hey guys -- I have a form I'm trying to use validation on but the form is dynamic.

http://sitename/event/register/<?= $event_id ?>

The form view pulls event specific stuff from the database depending on the event_id (title, date, description, etc). So there is not an actual 'form' view.

So if validation fails I cannot just
Code:
$this->view->load('form');
because I need to pass something more along the lines of
Code:
$this->view->load('form/<?= $event_id ?>')
which obviously doesnt work. I'm having to use a redirect
Code:
$this->validation->set_rules($rules);
    
      if ($this->validation->run() == FALSE)
      {
        redirect('/event/register/' . $event_id, 'refresh');
      }
But redirect doesn't pass the validation errors (or any variables for that matter (AFAIK)).
Could anyone shed some light on this for me? A possible solution or let me know if I going about this the wrong way.

Many thanks -
.adam.


Validation with redirect? - El Forum - 01-28-2008

[eluser]Craig A Rodway[/eluser]
You could set the event ID as a hidden field in the form, and use this to check which form to load on the re-validation.


Validation with redirect? - El Forum - 01-28-2008

[eluser]Huan[/eluser]
I agreed with Craig