fatal error: how to solve this

Permalink 1 user found helpful
I get this error, how to solve this error

Fatal error: Call to undefined method View::redirect() in /home/kumar/public_html/amsConcrete/single_pages/employee/add_employee.php on line 11


thanks
Kumar

 
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
You can't do a redirect from the view -- by the time the view is run, there is already content outputted to the browser (and redirects only work as headers, which must be sent before any content).

You could use a JavaScript redirect, which works the same as it does anywhere else (so nothing specific to concrete5). Or you could put the redirect into a page controller (this is a bit more complicated, and really depends on exactly what you're trying to do -- i.e. under what circumstances are you wanting to redirect people and to where do you want to redirect them?)

Rony
shankumars replied on at Permalink Reply
Hi rony,
actually i am save the new user details through method add_user()
after save i have to show the message to create successfully

controller:
function add_user(){
$ui = employeeinfo::adduser($data);
if(!isset($ui)){
$this->set('response', t('Save Successfully'));
}
$this->redirect('employee/add_employee');
}

single page:
if (isset($response)) { 
   echo $response;
 }


I want refresh page as well as i want to show the message success. but the page is refresh but not show the message vice verse .

thanks now i get idea by using the script to refresh but i dnt know message will show or not?

thanks
Kumar
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
Something like this would help!
$this->redirect('/employee/add_employee/', 'emp_added');

then create a function called "emp_added" and set your message.
function emp_added(){
 $this->set('message', t('Employee added successfully.'));
}


Rony
shankumars replied on at Permalink Reply
Hi thanks rony, the idea is good...