Hello, i have login page and, for example, i need get data from this form, filter and validate.
Im creating loginform class that extends Phalcon\Forms\Form and adding following element in initialize function:
$email = new Text('email',
[
'placeholder' => 'e-mail',
]
);
$email->setFilters(
[
'email',
]
);
$email->addValidators(
new Email(
[
'message' => 'text'
]
),
]
);
In controller action that handle data from this form i have the following code:
$loginForm = new LoginForm();
if ($loginForm->isValid($this->request->getPost())) {
...
}
And my question: How I can filter data for this element or at once for all elements? I read documentation and i know that I can create Filter class and use function "sanitize", but is it correct solution for my example? If this is correct solution so then for what Im adding filters in form initialize?
As I think, it must work before validation automatically, but its not working.