On Thu, May 23, 2013 at 2:26 AM, Andreas Möller <[email protected]> wrote: > I was just wondering how you would go about and solve the following problem: > > * You've got a form with elements that should allow a user to edit data which > may have different representations depending on the currently chosen locale > (for example: floats, dates) > * Employing filters, the values are normalised and persisted. > * When editing previously saved data, you want to render the values > (populate) the form with the representation fitting to the currently chosen > locale. > > So, similar to filtering the values before persisting them, they should be > filtered so the user is presented the values as she entered them into the > form. > > For example, if you have a form element used for editing a float, you > probably have filters applied so when for example you enter the string 3,1415 > in de_DE, it will be filtered to 3.1415 which you can persist as an actual > float (DECIMAL) in the database. However, when you populate your form with > the data extracted from your model, the value will be the float 3.1415 and > both the representation of the value is not what you would expect and the > form element will not validate. > > How would you solve this problem?
That's a view layer issue. In my view script, I'd extract any elements that I know need localization, and prepare them accordingly before rendering them. This might involve extracting the value, localizing it, and then passing it back into the element, or it might involve manually rendering the HTML for that particular element. Either way, however, that's a job to do in the view. -- Matthew Weier O'Phinney Project Lead | [email protected] Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc -- List: [email protected] Info: http://framework.zend.com/archives Unsubscribe: [email protected]
