Zend Framework 2 Form and InputFilter retuning different values

240 views Asked by At

I have a element(Select) of name,parameter. The problem is that on validation it returns error like this:

The input was not found in the haystack

I know that this is returned by InArray Validator. But, how can this happen when the input is valid. So, I tried to inspect the form element and inputfilter. So, i did:

print_r($form->get('parameter')->getValue()); // returns frequency  
print_r($form->getInputFilter()->get('parameter')->getValue()); // returns 0

I just cant understand, why are they returning different values?

Here is the full code:

$postData = $request->getPost()->toArray();

$form->setData($postData);

print_r($form->get('parameter')->getValue());

if ($form->isValid()) {
    $alarm->exchangeArray($form->getData());
    $this->getAlarmMapper()->save($alarm);
    $changesSaved = true;
}
print_r($form->getInputFilter()->get('parameter')->getValue());
1

There are 1 answers

0
Gytis Vinclovas On

As far as I know, if validation fails your filter simply doesn't return a value, that's why it returns 0. So you should probably look inside your validation, why it fails to validate.