Closed bacinsky closed 8 years ago
The same problem. Any ideas?
And how to set a custom message for required field? Message generate without any validators https://github.com/zendframework/zend-inputfilter/blob/master/src/Input.php#L407.
As a temporary solution I rewrote the class method like this:
protected function prepareRequiredValidationFailureMessage()
{
$notEmpty = new NotEmpty();
$templates = $notEmpty->getOption('messageTemplates');
$message = $notEmpty->hasTranslator()
? $notEmpty->getTranslator()->translate($templates[NotEmpty::IS_EMPTY])
: $templates[NotEmpty::IS_EMPTY];
return [
// TODO remove this file
// @issue message translation fix https://github.com/zendframework/zend-inputfilter/issues/71
NotEmpty::IS_EMPTY => $message,
];
}
But I think it's even a more mess now.
does this help? https://github.com/zendframework/zend-inputfilter/pull/73
In #73 message still get from templates, without translation. https://github.com/larsnystrom/zend-inputfilter/commit/4fc84cd93fd90da68f216927ef6226c97927e330#diff-5e41c64803af5c0ad8ad84c3e25c834cR510.
return [
NotEmpty::IS_EMPTY => $templates[NotEmpty::IS_EMPTY],
you could set translated message with validator options, but yes this is not perfect. just as test I created PR https://github.com/larsnystrom/zend-inputfilter/pull/1 could you test with this?
PR #67 addresses this. PR #73 concerns being able to specify any message when the required validation fails.
I think this is solved in zendframework/zend-inputfilter (2.7.0)
.
How is it possible to translate NotEmpty::IS_EMPTY message?
https://github.com/zendframework/zend-inputfilter/blob/master/src/Input.php#L497