How do I get data of post variables ? Like if I post form with post method then I can get itt with $_REQUEST or with $_POST. How I can do this in mgento ?
You can read the values with
$this->getRequest()->getParam('field_name');
The code above will get you values from GET
and POST
.
But if you want to check if something was sent specifically through POST
you can get it like this.
$this->getRequest()->getPost('field_name');
You can even specify a default value.
$somevar = $this->getRequest()->getParam('some_var', 7);
this means that if $_POST['some_var']
is not set, the variable $somevar
will have the value 7
.