I am setting up some filters and validators for my form, but when I submit it, this error appears: "Zend\I18n\Filter component requires the intl PHP extension". Is this because of the Alnum and Alpha validators ?
Code:
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 символа",
),
),
),
),
)));
}
Fixed it by going to php.ini and uncommenting extension=php_intl.dll
On Ubuntu 16.04, with php 5.6, try:
sudo apt-get install php5.6-intl
and then
sudo service apache2 restart
On Ubuntu 18.04, with PHP 7.2, try:
sudo apt-get install php7.2-intl
sudo service apache2 restart
If don't works enable extension=php_intl.dll in:
vim /etc/php/7.2/apache2/php.ini
sudo service apache2 restart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With