在使用Zend Framework验证功能时,我遇到了以下错误:
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception'
with message 'Plugin by name '0' was not found in the registry; used paths: Zend_Validate_: Zend/Validate/'
in /var/www/platform/lib/Zend/Loader/PluginLoader.php:406
Stack trace:
#0 /var/www/platform/lib/Zend/Filter/Input.php(1108): Zend_Loader_PluginLoader->load('0')
#1 /var/www/platform/lib/Zend/Filter/Input.php(1089): Zend_Filter_Input->_getFilterOrValidator('validate', Array)
#2 /var/www/platform/lib/Zend/Filter/Input.php(867): Zend_Filter_Input->_getValidator(Array)
#3 /var/www/platform/lib/Zend/Filter/Input.php(786): Zend_Filter_Input->_validate()
#4 /var/www/platform/lib/Zend/Filter/Input.php(414): Zend_Filter_Input->_process()
#5 /var/www/platform/app/controllers/admin/MatchfindersubjectsController.php(90): Zend_Filter_Input->hasMissing()
#6 /var/www/platform/lib/Zend/Controller/Action.php(513): Admin_MatchFinderSubjectsController->addAction()
#7 /var/www/platform/lib/Zend/Controller/Dispatcher/Standard.php(289): Zend_C in /var/www/platform/lib/Zend/Loader/PluginLoader.php on line 406
使用此代码时:
/**
* Handle the index
*
* @return void
*/
public function addAction()
{
$filters = [
'subject' => 'StringTrim',
'gender' => 'Digits'
];
$validators = [
'subject' => [
'presence' => 'required'
],
'gender' => [
new Zend_Validate_Int(),
[ 'Between' => 0, 2 ],
'Digits'
]
];
$data = new Zend_Filter_Input( $filters, $validators );
$data->setData( $_POST );
$x = $data->hasMissing();
die( var_export( $data ) );
}
我似乎无法找到:
答案 0 :(得分:1)
问题是你的验证者。
尝试更改
[ 'Between' => 0, 2 ],
通过
new Zend_Validate_Between(['min' => 0, 'max' => 2]),