M
M
Mikha Pankratov2015-03-13 18:25:31
Yii
Mikha Pankratov, 2015-03-13 18:25:31

Why doesn't the controller save Cyrillic?

Hello again,
so I registered the rules and regular

return [
            ['username', 'filter', 'filter' => 'trim'],
            ['username', 'required'],
            ['username', 'match', 'pattern' => '#^[\w_-А-Яа-я\.]+$#i'],
            ['username', 'string', 'min' => 2, 'max' => 255],

Sent to the controller
But save does not work ...
I understand the problem here
public function signup()
    {
        if ($this->validate()) {
            $user = new User();
            $user->username = $this->username;
            $user->lastname = $this->lastname;
      //...
 
            if ($user->save()) {
             // .....
            }
            return $user;
        }
 
        return null;
    }

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Semenko, 2015-03-14
@frmax

Well, at least you have an error in the regular expression. First, the hyphen needs to be escaped if it's not a range. Secondly, \w already contains the Russian alphabet and an underscore, like )

P
Philipp, 2015-03-13
@zoonman

u(PCRE_UTF8)
php.net/manual/en/regexp.reference.unicode.php
php.net/manual/en/reference.pcre.pattern.modifiers.php

M
Mikha Pankratov, 2015-03-13
@frmax

I checked,
the connection to the database,
the table in the database, each field, I
also checked the files - utf8
Here, but still - saving does not work, more precisely, it does not give an error "type saves" I look in the database and there is no record. As soon as I change to EN, everything saves. Is it because Fri 13th chtoli?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question