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

$this->request->getPost($name , $filters, $defaultValue); $defaultValue is not working

$this->request->getPost($name , $filters, $defaultValue);

like this code no set the defaultvalue

$data ['phone'] = $this->request->getPost(‘phone’ , 'int', '123456');
echo $data ['phone'] ; // out put  null 

this code outputs null, but I want the result : 123456

edited Aug '14
 * @param string $name
 * @param string|array $filters
 * @param mixed $defaultValue
 * @return mixed
public function getPost($name=null, $filters=null, $defaultValue=null){ }

$defaultValue how does it work?

edited Aug '14

defaultValue is applied if _POST phone doesn't exist, if you want add defaultValue if field is empty, set fourth parameter as true:

$this->request->getPost(‘phone’ , 'int', 123456, true);
     * @param string name
     * @param string|array filters
     * @param mixed defaultValue
     * @param boolean notAllowEmpty
     * @param boolean noRecursive
     * @return mixed
    public function get(string! name=null, filters=null, defaultValue=null, notAllowEmpty=false, noRecursive=false)


@Mariusz Łączak Hi Think you reply My carelessness; Didn't see was five arguments /*