Yii2: Unique Validator shows generic message when rule fails

Created on 21 Nov 2016  路  3Comments  路  Source: yiisoft/yii2

Hello,

It appears that for some reason the message specified for unique validators do not show up when validation fails rather a generic message is shown?

What steps will reproduce the problem?

Add a unique rule with a custom message to a model involving more than one column

What is the expected result?

When the rule fails the custom message provided in the rule should be displayed eg;
This Book and Author are already associated

What do you get instead?

A generic message like the following is displayed eg;
The combination "1"-"1" of Book, Author has already been taken.

Additional info

| Q | A
| ---------------- | ---
| Yii version | 2.0.9
| PHP version |5.6
| Operating system |Linux/Ubuntu 14.04.3

public function rules()
{
    return [

...
[['book_id', 'author_id'], 'unique', 'targetAttribute' => ['book_id', 'author_id'], 'message' => 'This Book and Author are already associated'],
...
];
}

Most helpful comment

Thanks @rob006, will update to 2.0.10 and provide feedback

All 3 comments

Thanks @rob006, will update to 2.0.10 and provide feedback

Glad to report that updating to 2.0.10 resolved the issue, thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vercotux picture vercotux  路  47Comments

schmunk42 picture schmunk42  路  47Comments

samdark picture samdark  路  63Comments

Mirocow picture Mirocow  路  56Comments

schmunk42 picture schmunk42  路  125Comments