It’s not really in the spirit of the MVC framework, but I can’t think of a better way to do this…
I have a controller method which loads a view for a generic new account setup:
function createAccount() {
$this->load->view('create_account');
}
function createAccount() {
$this->load->view('create_account');
}
function createAccount() {
$this->load->model('State');
$data['stateDropDown'] = $this->State->generateStateListDropDown();
$this->load->model('Country');
$data['countryDropDown'] = $this->Country->generateStateListDropDown();
$this->load->view('create_account'. $data);
}
This is desirable for me because it makes the Controller cleaner, and I would have to repeat the steps involved in generating the dropdowns every time I wanted to use it.
When I try to load a model from within a view, I get the following error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Loader::$State
Filename: views/stateList.php
Line Number: 4
Fatal error: Call to a member function generateStateDropDown() on a non-object in /home/lee/Development/CodeIgniter_1.5.4/system/application/views/stateList.php on line 4
Can someone suggest a cleaner implementation?
Cheers,
Lee
