framework icon indicating copy to clipboard operation
framework copied to clipboard

Is there a method overwriting $_POST?

Open circle8z opened this issue 9 years ago • 5 comments

After checking if the request failed to pass validation, I want to use the filtered values as the form's values. Example:

$filteredValues = $this->validation->getValues();
$this->request->setPost($filteredValues);

circle8z avatar Feb 01 '16 15:02 circle8z

You can use replace() or setData(), because request's post is an Arr.

$this->request->getPost()->replace($this->validation->getValues());

Remember that this not overwrite the _POST due to https://github.com/phalcon/zephir/issues/203, so after replace:

$_POST['username']; // still original
$this->request->getPost('username'); // filtered

mruz avatar Feb 01 '16 15:02 mruz

Your advice was helpful. Thank you very much!!

circle8z avatar Feb 02 '16 13:02 circle8z

Is it _POST overwriting required in the future? What do you think?

mruz avatar Mar 06 '16 17:03 mruz

I thought that I need to use _POST overwriting, because Ice\Tag class use _POST. The issue will probably be solved by the following example. What do you think?

$this->request->getPost()->replace($this->validation->getValues());
$this->tag->setValues($this->requrest->getPost());

circle8z avatar Mar 10 '16 17:03 circle8z

Yes, you can set values:

$this->tag->setValues($this->requrest->getPost()->getData());

mruz avatar Mar 10 '16 19:03 mruz