Well if everything runs through the model you could modify the getters to take an argument that will format the number appropriately. Or you could add a behavior that does this and then apply the behavior to model/properties you want this to happen to.
Tomasz Ignatiuk wrote: > Heheh...Lee I'm not talking about functions in php :) > > I'm talking about how to do something like this... > Write some action or filter or something which will automatically return > formated number. For example you have fields price_netto, price_brutto, > price discounted. Normally I would alter template and do this: > <?php echo number_format($price_netto, 2); ?> > > which echo this: 156.70 (in DB there is 156.7) > > and do it for each field. So i am thinking about some Hook or something > which will do number_format automatically. So in templates I leave this: > <?php echo $price_netto; ?> > > which will also echo this: 156.70 (in DB there is 156.7) > > :) > 2009/2/11 Lee Bolding <[email protected] <mailto:[email protected]>> > > > You mean number_format? > > Hell, why not use money_format? > > There's a bunch of native PHP ways to deal with it. > > Native PHP is definitely the way I'd tackle this problem. Widgets seem > wrong - instantiating extra objects when there is native > functionality? err... > > Automatically converting a number to a different format to that stored > in the database is asking for problems - it's stored like it is for a > reason. > > > On 11 Feb 2009, at 17:41, Martino Piccinato wrote: > > > > > widget where brought in beacuse apparently the problem was about > > number formatting in forms. > > > > if talking about view sprintf is definitely overkill compared to > > "number" > > > > <?php echo number($model->getPrice(), 2);?> > > > > ;-) > > > > > > > > On Wed, Feb 11, 2009 at 6:34 PM, Lee Bolding <[email protected] > <mailto:[email protected]>> wrote: > >> > >> any reason you can't use sprintf???? > >> > >> All this talk of filters, widgets... it's a little overkill, isn't > >> it? > >> > >> <?php echo sprintf("%01.2f", $model->getPrice()); ?> > >> > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---
