Issues

ZF-6359: Filters should work for UTF8 strings when used in Zend_Form

Description

Zend_Filter offers $filter->setEncoding('utf-8'), but when used with Zend_Form developer can't set that anywhere cetrally. There should be a static call to set encoding to UTF-8 for all filters application-wide.

Current workaround is to create Filters separetly and set encoding for each of them.

Comments

Lowering priority as there is already a workaround.

Note that such a change would introduce a BC and would therefor only be allowed for ZF2.0

What is BC? Backward Compatibiliry? How would that affect BC. Z_Filter already has abbility to work with UTF-8 (via setEncoding()) so it could be done somehow in Zend_Form... like $form->setEncoding('UTF-8') and this will be send to every filter in form via setEncoding().

Developer then can extend Zend_Form to set encoding in init().

Changing Instance to Static within Zend_Filter as proposed would mean that it is no longer possible to set one filter to UTF8 and another one to ISO for example.

This is definitly a BC break and therefor ONLY allowed for major releases.

Ah, I see... I doesn't have to be static call... that was just an idea ;) The thing I wanted was "Filters should work for UTF8 strings when used in Zend_Form". It's not important how it will be done. It can be done in cycle from Zend_Form for example... I don't feel like qualified enough to make the choice where and how.

I can see a potential for an element level "setFilterEncoding", and a form level "setFilterEncoding" method. But then the question arises of whether there should just be "setEncoding" methods -- and would those propagate to the view helpers as well? There's a lot to consider here. None of these would be BC violations -- but all are non-trivial to add.

I would propose the following:

Filters should be allowed to set encoding per filter as actually done. Additionally it should be possible to set the encoding as option (options array should be allowed by all filters and partitially they are already).

Form should add encoding option.

When Form sets encoding then this encoding should be used within the attached filter of this form. EXCEPT a encoding has manually be specified to the filter. So only the default encoding should be set by Form.

This way would allow to set encoding once within Zend_Form and promote it to the filters. And it would allow to set a different encoding to special filters when this should be necessary.

All filters support now 'encoding' as options array when they have UTF-8 support. Therefor detaching Zend_Filter from the issued components.

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.