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 символа",
                            ),
                        ),
                    ),
                ),
            )));
          }
Milen Pivchev
  • 1,417
  • 2
  • 16
  • 29
  • 2
    possible duplicate of [Unable to use Zend\I18n\View\Helper\CurrencyFormat class](http://stackoverflow.com/questions/25771519/unable-to-use-zend-i18n-view-helper-currencyformat-class) – Paweł Tomkiel May 14 '15 at 17:20
  • @Milen can you answer the question then? Please don't leave it unanswered. – Michal M. May 15 '15 at 07:09

4 Answers4

11

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

Milen Pivchev
  • 1,417
  • 2
  • 16
  • 29
4

On Ubuntu 16.04, with php 5.6, try:

sudo apt-get install php5.6-intl

and then

sudo service apache2 restart
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
JorgeM
  • 617
  • 5
  • 11
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

Community
  • 1
  • 1
Anatolii Pazhyn
  • 1,442
  • 13
  • 7