S
S
Sergey Pugovkin2017-03-19 00:10:34
Yii
Sergey Pugovkin, 2017-03-19 00:10:34

Why is {attribute} not being replaced with the attribute name?

In the model

$this->addError('email', '{attribute} уже занят.');

Prints '{attribute} already taken.'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2017-03-19
@Driver86

messages of the format '{attribute} already taken.' support built-in validators, but you add error messages through the addError model method, which does not support this message format. Specify the attribute name explicitly, for example:
$this->addError('email', 'email уже занят.');

L
lem_prod, 2017-03-19
@lem_prod

$this->addError('email', "{$attribute} is already taken.");
https://secure.php.net/manual/en/language.types.st... read

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question