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

Flash old input

When I search google with keyword "flash old input phalcon", it lead me to "https://forum.phalcon.io/discussion/1918/keep-old-inputs" but Phalcon\Tag didn't use Flash Session.

My way is hook HTTP Request then save variables in Flash Session. Anyone have a idea to resolve this trouble ?



4.5k
edited Nov '14

I know it's an old thread but I have been trying to flash old inputs for ages now and finally found a workaround. However it's really ugly and I was wondering if anyone has any better solution?

In the post submit action

            foreach($this->request->getPost() as $key=>$msg)
                {
                    $this->persistent->$key = $msg;
                }   
                return $this->response->redirect('/submit');

In get action

    if($this->session->has(__CLASS__))
    {
        \Phalcon\Tag::setDefaults($this->session->get(__CLASS__));
        $this->session->remove(__CLASS__);
    }

It will set input fields with old values and deletes them after refresh.