我正在为表单设置一些过滤器和验证器,但是在提交表单时,会出现此错误:“Zend\I18n\Filter组件需要intl PHP扩展名”。这是因为有Alnum和Alpha验证器吗?
代码:
public function getInputFilter() {
if (!$this->inputFilter) {
$inputFilter = new InputFilter();
$inputFilter->add(array(
'name' => 'email',
'required' => true,
"filters" => array(
array('name' => 'StringTrim'),
array('name' => 'StripTags')),
'validators' => array(
array(
'name' => 'Regex',
'options' => array(
'pattern' => '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/',
'messages' => array(
Regex::NOT_MATCH => 'Е-майл адреса е невалиден.',
),
),
'break_chain_on_failure' => true
),
array(
'name' => 'EmailAddress',
'options' => array(
'messages' => array(
EmailAddress::INVALID_FORMAT => "Е-майл адреса е невалиден.",
EmailAddress::INVALID => "",
EmailAddress::INVALID_LOCAL_PART => "",
EmailAddress::INVALID_HOSTNAME => "",
EmailAddress::INVALID_SEGMENT => "",
EmailAddress::DOT_ATOM => "",
EmailAddress::INVALID_MX_RECORD => "",
),
),
),
),
));
$inputFilter->add((array(
'name' => 'name',
'required' => true,
"filters" => array(
array('name' => 'StringTrim'),
array('name' => 'StripTags')),
'validators' => array(
array(
'name' => 'Alpha',
),
),
)));
$inputFilter->add((array(
'name' => 'password',
'required' => true,
"filters" => array(
array('name' => 'StringTrim'),
array('name' => 'StripTags')),
'validators' => array(
array(
'name' => 'Alnum',
),
array(
'name' => 'StringLength',
'options' => array(
'min' => 6,
'max' => 12,
'messages' => array(
StringLength::INVALID => "Паролата трябва да е от 6 до 12 символа",
),
),
),
),
)));
}
最佳答案
通过转到php.ini并取消注释extension=php_intl.dll
来修复它