php - Best practice linking back to source view -


i have several views show detail edit button. when user clicks on edit button, go edit view item. edit view want link original view. best practice people use edit view knows take user to?

i using php laravel framework.

example:

user on /invoice/1/detail, click on edit /contact/9/edit, click on save or cancel, go /invoice/1/detail

or

user on /task/2/detail, click on edit /contact/9/edit, click on save or cancel, go /task/2/detail

or

user on /report/3/detail, click on edit /contact/9/edit, click on save or cancel, go /report/3/detail

you benefit resource controllers (http://laravel.com/docs/4.2/controllers#restful-resource-controllers) if you're willing take plunge. after adopting those, detail views look

public function show($id) {...} 

and edit views like

public function edit($id) {...} 

and routing more or less handle itself.

assuming you've adopted convention, can put common logic in base controller , have individual controllers extend them.

a base controller have stuff this:

<?php  use illuminate\routing\controller controller;  class basecontroller extends controller {     /**      * returns routable action string editing resource      * @return string      */     final protected function geteditaction()     {         return __class__ . '@edit';     }      /**      * returns routable action string showing resource      * @return string      */     final protected function getshowaction()     {         return __class__ . '@show';     } } 

then, controller extending base controller, stuff this:

// redirect detail page upon save return redirect::action($this->getshowaction());  // pass link detail page view return view::make('foo.bar', ['back_url' => url::action($this->getshowaction())]); 

and on.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -