Farshid
Farshid

Reputation: 518

How can set language to attribute in Yii2

I want to set language to attribute like this:

public function rules() {
    return [
        ['name', 'language' => 'ru', 'message' => 'Just enter the Russian.]
    ]
}

Upvotes: 0

Views: 56

Answers (1)

Mohammad Aghayari
Mohammad Aghayari

Reputation: 1170

Try this:

public function rules() {
    return [
       ['name', 'match', 'pattern' => '/[а-ѩA-Ѩ]+$/u', 'message' =>Yii::t('app', 'Just enter Russian') ]
    ]
}

Upvotes: 2

Related Questions