Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP: how to use Controller::referer() in a view

I'm getting the following error:

Strict (2048): Non-static method Controller::referer() should not be called statically,
assuming $this from incompatible context [APP/View/Questions/admin_edit.ctp, line 20]

Caused by this:

//in app/View/Questions/admin_edit.ctp
echo $this->Html->link('Cancel', Controller::referer() );

Why?

like image 282
emersonthis Avatar asked Apr 17 '13 20:04

emersonthis


1 Answers

You don't. You use the request object instead:

$this->request->referer();

The controller does nothing else internally.

Careful: the referer can be empty and thus you might want to provide a fallback here in that case.

Also note the optional param $local:

@param boolean $local If true, restrict referring URLs to local server

like image 156
mark Avatar answered Nov 06 '22 14:11

mark