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());
据我所知,如果验证失败,则过滤器根本不会返回值,这就是它返回0的原因。因此,您可能应该查看验证内部,为什么它无法验证。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.