Does someone know an example of adjusting validators’ error messages dynamically? Something like via a callback.
For example, I have a validator for uniqueness of certain fields in DB, and error message is currently defined something like this:
'message' => 'Such a record does exist already'
But I’d like the message to contain a link to the existing record. Of course, validator “knows” invalid $object and all its fields values. The problem is that this info is available in the validator’s validateAttribute method only, not outside. If it could be passed via callback to validator’s host, then it can be used to call findByAttributes and get model ‘id’, then to construct url for this existing model.