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

filter form element [SOLVED]

I have a simple form.

$country =  new Text('country', array('required' => true,'class' => 'span12', 'data-sort' => 5));
$country->addValidator(new PresenceOf(array('message' => 'Пожалуйста,  укажите страну проживания.')));
$country->setFilters(array('trim, string'));
$country->setLabel('Страна');

/* other elements */

in cntrl

form->bind($_POST, $userEntity);

I get exception

Phalcon\Filter\Exception: Sanitize filter trim, string is not supported

but when I change setFilters to addFilter it works correct. What I'm doing wrong?

Problem solved: setFilters(array('trim', 'string'); =)



12.8k
edited Feb '17

you have error in setFilters method. Should be:

$country->setFilters(array('trim', 'string'));