开发者

Can I change hash error message "No token was provided to match against" "The two given tokens do not match"

I want to change the default error messages "No token was provided to match against" and "The two given tokens do not match". For the second one (tokens don't match), I thought readding the Identical validator would do it, but in the form I don't have access to the $value_to_match_against so maybe this is the wrong way. For the first one (no token provided), I don't know how to change it at al开发者_运维技巧l.

->addValidator('Identical', true, $value_to_match_against, $msg);


A simple search on Stack Overflow gives quite a lot of different way to do it:

  • By using .ini files
  • Altering the element or using SetMessages
  • Using options in an array definition
  • Using translation files

All these ways are valid, choosing the best depends on how you manage your code/application/classes. The most important point is to get either the name or the constant of the available error messages. You can find they quite easily by reading the source code of the Validator you are using (usually on top of these files), or by using the translation files.


If you are trying to do this via an ini, the structure is slightly different:

elements.csrf.options.errorMessages.Identical = "This form has timed out for secrity purposes. Please try again."
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜