How to remove url after submit form

Hi all I wan to remove url http://duythien.dev/eduapps/admin/hososinhvien/edit/7 gold http://duythien.dev/eduapps/admin/hososinhvien/ i using return $this->dispatcher->forward(array('action' => 'index')); but not remove url above, how to hint



35.1k

use $this->response->redirect()



37.9k

but $this->flash->success("Đã xóa thành công"); not working



35.1k

When using redirect, you must use session flash. $this->flashSession->success("Đã xóa thành công");



37.9k
edited Mar '14

I using session flash. but working

if ($this->uploadImg($request->getPost('MaSV')) == true) {
                    if($Hososinhvien->update()) {
                    $this->flashSession->success("Cập nhật thành công: ".$Hososinhvien->MaSV);
                    Tag::resetInput();
                    return $this->dispatcher->forward(array('action' => 'index'));
                    //return $this->response->redirect('admin/hososinhvien');

                    }
                }


6.0k

The problem is that you don`t understand, how forward works.

Forward forwards your action to another action into SERVER SIDE. It means, that you are still doing same request, which is your current form POST request. To see flash message you need to do redirect instead of forward, because flash message is stored in session, and it gets removed and attached to get method after each request from user client(browser).

Easily forward works like: POST request -> action(with post request url) -> forward action(url is still from post request) -> response to user browser And redirect works like: POST request -> action(with post request url) -> response to user browser(redirect url)