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

Tag::resetInput() and code update in Vökuró sample app

Hi,

I am still kind of new to Phalcon and Vökuró was my first canvas to start using Phalcon for something meaningful, however, since it was still using Bootstrap 2.3.1, I had issue initially following it. Hence, when I am little more aquaintted with Phalcon, decided to upgrade Vökuro myself to Bootstrap 4.1.1, now after couple of week's work (in my spare time) , you can find it at : https://github.com/MoHasanJ/vokuro , have already submitted PULL request today.

Apart of major changes in volt / VIEWS, I made smaller changes in other parts , one being was removal of Deprecated Tag::resetInput(); I wanted to remove it as for first time when I was learning , it created quite an issue for first time learner.

I replaced with $form->clear() where it was possible, but I am not sure at some place like in ProfilesController.php

  public function createAction()
    {
        if ($this->request->isPost()) {

            $profile = new Profiles([
                'name' => $this->request->getPost('name', 'striptags'),
                'active' => $this->request->getPost('active')
            ]);

            if (!$profile->save()) {
                $this->flash->error($profile->getMessages());
            } else {
                $this->flash->success("Profile was created successfully");
            }

            // Tag::resetInput();
        }

        $this->view->form = new ProfilesForm(null);
    }

How can I clear form after submission when it returns. I can still see older data still available in create action. $form->clear() is not available in thie method.



702
Accepted
answer
edited May '18

Nevenrmind, I figured it out , all I need is to use instance of FORM class and in above example, adding $this->view->form->clear(); solves it easily.