Reputation: 635
This is confusing to me. I'm manually converting my cakephp 1.3 application to 2.0 to understand it better rather. Everything seems to be working, but for some reason the $this->redirect() function isn't working. It just leaves me with a blank screen.
My code is:
class TimeslotsController extends AppController {
var $helpers = array ('Html','Form', 'Calendar');
var $name = 'Timeslot';
var $uses = array('User', 'Timeslot', 'TransLog', 'Credit', 'Section', 'StudentSection', 'Assignment', 'Call') ;
var $components = array('Calendar', 'Local', 'Email');
function index() {
$this->redirect('admin/user/37');
}
}
Am I missing something on how cake 2.0 handles redirects?
Thanks!
Upvotes: 1
Views: 1141
Reputation: 2189
if there is a whitespace in AppController or in PageController , it prevents header to be set , and hence redirect doesn't work. check for white space before php code if all above syntex doesn't work
Upvotes: 0
Reputation: 34877
You can try two things. Either use an absolute URL, thus starting with a / like:
$this->redirect('/admin/user/37');
Or (better way) write it in full, like:
$this->redirect(array(
'admin' => true, // Requires admin routing prefix in Config/core.php
'controller' => 'user',
'action' => 'index',
37
));
Upvotes: 1