Issues

ZF-4150: Zend_Form_Element_File doesn't translate error messages

Description

Greetings,

I use zend translator with my forms to translate error messages, and it goes well. But this doesn't work with file form element. I found a fix and I place the diff in attachment.

To fix the problem I try to reproduce the behavior of the other form elements. So first, the Zend_Form_Element_File#isValid function had to pass the translator on the transfer adapter by using the Zend_File_Transfer_Adapter_Abstract#setTranslator method. Then, the transfer adapter does the same thing by calling setTranslator on validators that have the method (such as Zend_Validate_Abstract). The last thing that need to be added, is the Zend_File_Transfer_Adapter_Abstract#setTranslator method. Normally, validators have this method, but the transfer adapter inherits from Zend_Validate_Interface and not Zend_Validate_Abstract. In the fix, I suggest to change the inheritance because it doesn't need a lot of changes. But I think that require more cpu and memory usage and perhaps that will cause others problems.

I work on the 11181 Zend Framework revision.

Thanks for reading.

Comments

Diff file that patches the translation file form element problem.

Code can not be used as is... implementation problems with other new features

Which part of the code affects these new features ? An other solution may be to call :


parent::isValid($value, $context);

in the Zend_Form_Element_File#isValid method. But I think this would require more modifications.

Otherwise how can this bug be fixed ? I use a lot of translation with forms and I would appreciate a solution with file elements. If I can help by suggesting other solutions, I volunteer.

Should now work with latest trunk release. Please give it a test and me a response.

I will close this issue as resolved if there is no response until 23.Sept.

Not sure what happened to the original person who reported this, but this doesn't appear to be fixed in 1.6.2

If you specify a translator via Zend_Form using setDefaultTranslator, the translator is still null when processed by Zend_File_Transfer_Adapter_Abstract.php so the error message is not being translated.