I can't figure out how to get filtered values from a form.
For example in controller I'm just creating a form and check if it's valid or not:
$editPersonFormObject->setData($this->getRequest()->getPost());
if ($editPersonFormObject->isValid()) {
// saving logic
}
The form contains "name" element:
$nameObject = new Text('name');
$nameObject->setValue($personRowObject->name);
and implements the "getInputFilter" method:
$this->filter = new InputFilter();
$this->filter->add(
array(
'name' => 'name',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim')
),
...
return parent::getInputFilter();
And it's ok for validating: a validator gets filtered value without spaces, tags and etc, but when I try to save the value in my model:
$personRowObject->name = $formObject->get('name')->getValue();
I'm getting the unfiltered value with spaces. Even when I'm trying to get the value via FormInput Filter:
$formObject->getInputFilter()->getValues();
I get an array of empty values:
array(1) {
["name"] => string(0) ""
}
What am I doing wrong?