Welcome Guest, Not a member yet? Register   Sign In
Re-Direct vs Load View - Help Please!


I'm fairly new to CodeIgniter and I'm having some issues with re-direct vs loading my view when a form is submitted successfully and/or unsuccessfully. I want to use view, because with re-direct I'm having to put all my validation errors and POST data in sessions which is very annoying.

Here's a break down of the user process...

1.) User selects a company from a data table.
2.) User chooses to Add Location for this company and the form opens up with following URL: http://virtue-dev/administration/vendors/add_vendor_location/2

How do I load this view without having to do a re-direct?

Will not work:
$this->load->view('administration/vendors/add_vendor_location/ID Goes Here');

I get the following error:
Unable to load the requested file: administration/add_vendor_location/2.php


You shouldn't have to worry about input and errors.
In short you should use $this->load->view() when you need to retain the input data and redirect() when you're done.
Something like this:

function theform()
  if ($this->form_validation->run() == TRUE)  // If no validation errors
    // Insert code to handle form input
    // We no longer need the input data so redirect to start with a clean slate - especially if the page we're loading now is the form

  // We'll only get here if form_validation is false
  $this->load->view('theFormView', $this->data);
}  /* End of function theform() */

I'm just off to bed so may have misunderstood your question but I hope this helps Smile

Theme © iAndrew 2016 - Forum software by © MyBB