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

Volt: how do you pass (post) data from your view.volt to its corresponding controller

Hello there,

I've been using the docs to figure out how to send data to a volt view, and that seems pretty straight forward. But how do you pass data back to the controller on submit using normal html form elements? Can anyone give an example?

Thanks

my form in volt same as form html. you can post from volt (html volt) form to controller and get data with :

$this->request->getPost("<name of your element input>");

and passing again to view volt with:

$this->view->mypost=$this->request->getPost("<name of your element input>");

to show data "mypost" in your view (volt) use this:

{{ mypost }}



2.6k
Accepted
answer

So for both we use $this->request->getPost? Is this in docs?

my form in volt same as form html. you can post from volt (html volt) form to controller and get data with :

$this->request->getPost("<name of your element input>");

and passing again to view volt with:

$this->view->mypost=$this->request->getPost("<name of your element input>");

to show data "mypost" in your view (volt) use this:

{{ mypost }}

edited Apr '15

use request in controller and passing to view from controller check phalcon request. https://docs.phalcon.io/en/master/api/Phalcon_Http_Request.html