1
votes

I'm working on a new project and I'm using subfolders with my Views and Controllers because it's going to be a fairly big application. My problem is I can not load a View with an Id. I'm getting "Unable to load requested file" error.

This will load my view, but because I don't have the Id needed in the URL I'm getting errors because some of the functions I have require it:

$this->load->view('administration/header');
$this->load->view('administration/add_vendor_location');
$this->load->view('administration/footer');

But when I try and include the Id like so:

$this->load->view('administration/header');
$this->load->view('administration/add_vendor_location/Id');
$this->load->view('administration/footer');

I'm getting the "Unable to load the requested file" error. I know I can use re-direct, but this is coming from a Form Validation and setting all the POST data and errors in sessions is very time consuming / annoying.

Hope this makes sense!

Thanks!

1

1 Answers

2
votes

In the code you provided, views/administration/add_vendor_location/Id.php must exist in order to load it.

If you're trying to pass a variable to the view, you would do so using an array in the secend parameter:

$this->load->view('administration/add_vendor_location', array(
    'id' => $id
));

See the CI View documentation