2017-07-24 107 views
0

我對電子郵件有簡單的ajax驗證。Yii2驗證消息不會改變

$rules[] = [['email'], 'unique', "message"=>"Email адресът {value} вече съществува!"]; 

但我的自定義消息不顯示。它總是返回默認信息:This email address has already been taken。任何線索爲什麼是這樣?我認爲這很簡單。如果我錯了?順便說一句,它是user dektrium模塊,如果有關係,請提前致謝!

回答

1

你應該返回

public function rules() 
{ 
    return [ 

    [['email'], 'unique', "message"=>"Email адресът {value} вече съществува!"]; 

    // the email attribute should be a valid email address 
    ['email', 'email'], 
    ]; 
} 

最終值,您應該擴展或重新定義用戶模型規則()函數