We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to remove url after submit form

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



51.1k

use $this->response->redirect()



58.4k

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



51.1k

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



58.4k
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');

                    }
                }


9.3k

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)