CakePHP: Flexible redirection for views and controllers -


i have views called different views. customers edit view can called customers list, customers search, within order , on. of views simple views other contains forms add, edit or delete data. after user has done had to on form should redirected calling form or form.

using $this->referer() wouldn't work navigations have go this:

list order --> edit order --> delete order --> list order.

i fine defining redirection every call i've tried use query strings , add ?redirecttarget=<wherever> every link or redirection. i've made controller function

in appcontroller.php

public function getredirecttarget() {     if ($this->request->query('redirecttarget')) {         return $this->request->query('redirecttarget');     } else {         return array(             'controller' => 'pages',             'action' => 'home'         );     } } 

this works forms can use getredirecttarget() in controllers cannot access function within view build link. (at leas sholdn't can call controller function view in cakephp? ) in example top have pass information order list edit view build link , underlying controller form action.

now have different aproaches in mind none of them i'm realy happy. i'm not shure way go.

  • is there in cakephp haven't found yet?
  • using $this->requestaction?
  • changing forms , buttons , doing redirections in controllers?
  • is there way create variable every view?

as seems me comon requirement , i'm pretty new cakephp i'm asking advice.

using requestaction should best way.

in views, can have

$redirect = $this->requestaction('/mycontroller/requestaction'); $url = $this->html->link('continue', $redirect)); 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -