Welcome Guest, Not a member yet? Register   Sign In
Form Validation > Redirect instead of loading a view?
#1

[eluser]jpschroeder[/eluser]
Hello,

I've decided to start using CI's built in form validation rather than my own flavor, but I have a couple concerns about how these are handled, primarily in the area of error handling. The userguide presents this code as an example of how a form should be validated:

Code:
if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('myform');
        }
        else
        {
            $this->load->view('formsuccess');
        }

My issue with this code is that all my forms submit to a custom form controller /form/__tablename__

So for example, I could have the following:

example.com/edit/_sometable_/1

and it submits to:

example.com/form/_sometable_

Obviously it would be bad practice to load the form view from this controller since its not even in the same class as the original, causing the urls to "seem" confused (the form wold appear on form/_sometable_ when it was originally loaded on edit/_sometable_/1). What I want to do is redirect back to the original form page if the validation fails and present the errors to the user there. Of course, the validation_errors() will no longer be accessible after a redirect. I understand the structure of this form submission may seem strange, but it makes my code much much more dynamic to do it this way.

This is somewhat confusing, so if needed just ask and I'll explain further. Thanks in advance for any help.


Messages In This Thread
Form Validation > Redirect instead of loading a view? - by El Forum - 07-22-2009, 03:20 PM
Form Validation > Redirect instead of loading a view? - by El Forum - 07-22-2009, 03:45 PM
Form Validation > Redirect instead of loading a view? - by El Forum - 07-27-2009, 11:43 AM
Form Validation > Redirect instead of loading a view? - by El Forum - 07-27-2009, 01:01 PM
Form Validation > Redirect instead of loading a view? - by El Forum - 07-27-2009, 01:23 PM
Form Validation > Redirect instead of loading a view? - by El Forum - 07-27-2009, 09:57 PM
Form Validation > Redirect instead of loading a view? - by El Forum - 09-01-2009, 05:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB