Reputation: 14184
I have a text field in a Zend_Form
that contains a numeric value. I would like that value to be rendered as though it had been run through number_format()
. For example, if the value in the field is 12345
, I would like it to appear in the text field as 12,345
.
On the submit side, I have a filter that strips the comma, giving me a clean numeric value when I eventually call $form->getValues()
. [For the moment, let's forget about the locale issue]
But how do I format the value that ultimately appears in the input field?
I guess I could:
Zend_Form_Element_Text
FormText
helperViewHelper
decorator on the form element itselfBut it sure seems like a whole lotta hoops through which to jump. Anything simpler?
Upvotes: 1
Views: 733
Reputation: 11212
Check out Zend_Locale_Format and set the value on your form element
$element->setValue(Zend_Locale_Format::getNumber($value, array('number_format' => $xx, 'locale' => $lang_LOCALE));)
Upvotes: 3