9

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 символа",
                            ),
                        ),
                    ),
                ),
            )));
          }
2

4 Answers 4

11

Fixed it by going to php.ini and uncommenting extension=php_intl.dll

2
4

On Ubuntu 16.04, with php 5.6, try:

sudo apt-get install php5.6-intl

and then

sudo service apache2 restart
0
1

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
0

If you are using XAMPP on MAC OS X add extension=intl.so into your /Applications/XAMPP/xamppfiles/etc/php.ini file and restart Apache. If it is still not working you need to install intl. You can follow the instruction here https://stackoverflow.com/a/32404183/3303055

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.