Zend Framework

Zend_Form_Element_File doesn't translate error messages

Details

  • Type: Patch Patch
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.6.2
  • Component/s: Zend_Form
  • Labels:
    None

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.

Activity

Hide
Adrien13 added a comment -

Diff file that patches the translation file form element problem.

Show
Adrien13 added a comment - Diff file that patches the translation file form element problem.
Hide
Thomas Weidner added a comment -

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

Show
Thomas Weidner added a comment - Code can not be used as is... implementation problems with other new features
Hide
Adrien13 added a comment -

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.

Show
Adrien13 added a comment - 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.
Hide
Thomas Weidner added a comment -

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.

Show
Thomas Weidner added a comment - 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.
Hide
l c added a comment -

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.

Show
l c added a comment - 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.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
Not Specified
Original Estimate - Not Specified
Remaining:
0m
Remaining Estimate - 0 minutes
Logged:
6h
Time Spent - 6 hours