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

I get 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]

Because of this:

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

Why?

+5
source share
1 answer

No. Instead, you use the request object:

$this->request->referer();

The controller does nothing internally.

Caution: the referent may be empty and therefore you may want to provide a backup here in this case.

Also note the optional $ local parameter:

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

+14
source

All Articles