【发布时间】:2014-08-24 13:59:00
【问题描述】:
使用 Zend 框架 1.6,我收到这样的 POST 请求:
array(2) {
["checkins"] => array(18) {
["nome"] => string(6) "MYNAME" //the field is correctly filled
["pec"] => string(0) ""
["sito_web"] => string(0) ""
["note"] => string(0) ""
}
["users"] => array(19) {
["email"] => string(29) "email@gmail.com"
["u_id"] => string(1) "1"
}
}
为了验证“nome”字段,我正在使用 Zend 输入过滤器。这是我的验证器数组:
$validators = array (
'nome' => array (
'presence' => 'required'
));
$params = $this->getRequest ()->getPost ();
$input = new Zend_Filter_Input ( array (), $validators,$params );
if (! $input->isValid ()) {
print_r($input->getMessages ());
}
似乎验证格式不正确,因为我收到了消息:
Field 'nome' is required by rule 'nome', but the field is missing
在我看来,我的 $validators 数组中有一个错误,但我找不到它。
【问题讨论】:
标签: php zend-framework