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

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 https://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 https://docs.phalcon.io/en/latest/reference/forms.html and add filtering/validation logic there as well: https://docs.phalcon.io/en/latest/reference/validation.html https://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())