We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

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.

Collect all post data at once

Hi,

I might be missing something in the docs, but is there a way to collect all Post data objects at once?

Right now, I get the Post data on a request like this:

$test->user = $this->request->getPost("user", "striptags");

Thanks for the help so far, Soda



26.3k
edited Aug '14

You can do it by this:


$all_post_data = $this->request->getPost(); // do not specify any arguments

It is described here http://docs.phalcon.io/en/latest/api/Phalcon_Http_Request.html

Unfortunetely I don't know how to get whole post array with filtering at the same time. Maybe this will work $this->request->getPost(null,"someFilter");?



13.4k
Accepted
answer
edited Aug '14

You could just create your form using the Forms Builder http://docs.phalcon.io/en/latest/reference/forms.html and add filtering/validation logic there as well: http://docs.phalcon.io/en/latest/reference/validation.html http://docs.phalcon.io/en/latest/reference/filter.html you can then validate your form against the submitted post request using $form->isValid($this->request->getPost())