Welcome Guest, Not a member yet? Register   Sign In
Problems with views
#1

[eluser]Unknown[/eluser]
Hi everyone,

I have one view that includes other views (main view include header, footer ), but the header and footer view have a couple of variables that are filled by controller (with model values).

My problem are in main view when i submit a form i call the controller "regist" method and in that method i have this code :

$this->load->model('data');
if($this->input->post('submit'))
{

if($this->data->regist()==true)
{
$data['cabecalho']="SUCESS";
$this->load->view('main_clock',$data);
}
else
{
$data['cabecalho']="ERROR!";
$this->load->view('main_clock',$data);
}

}


And when return to main view i have several error because the variables to fill in footer and header are cleaned, how i can resolve this problem?
I want basically reload to initial page when a user submit a form.

Regards.
#2

[eluser]Ckirk[/eluser]
Whatever variables are set in your index method should also be set in regist, if you want your header and footer views to work

You don't want to duplicate code so either initialise the variables in a private function or in the __construct().

I usually have a $data array set at the top of the class (above the __construct() ) so that it's available to any method within that class













Theme © iAndrew 2016 - Forum software by © MyBB