Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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 }}



1.1k
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. http://docs.phalconphp.com/en/master/api/Phalcon_Http_Request.html