I occasionally have form elements that I would like to apply filters
selectively depending on whether the value is to be displayed on screen or
used internally. One example would be form elements used for currency
values. When displayed in a form, I like adding
Zend_Filter_LocalizedToNormalized to the element so that the values will be
nicely formatted. The problem with this is getValue() returns the value as
a string rather than a float, since the normalized representation of the
value is a string representing a number. I realize in this specific case I
could do a simple type conversion from string to float, but other cases are
more complex.

It seems it would be incredibly useful to differentiate between what I
consider input filters (ie, filters that convert string input to integers,
floats, Zend_Date/DateTime) and output formatters for form elements. I
suppose this could be handled by restricting filters to only input
filtering and using decorators to handle the output formatting, but I have
some concerns. First, there are no standard decorators for ANY such case in
the library and I am hesitant to try to "glue" something on that might not
be the right fit. Second, it would create some decorators that could not be
nested inside other decorators.

Is there a better way to accomplish this?

Andrew

Reply via email to