getElement(); $options = array( 'mDec' => $element->getPrecision(), 'aNeg' => ($element->getNegative()) ? '-' : '', 'aSep' => $element->getGroup(), 'aDec' => $element->getDecimal(), ); $this->_initAppendPrepend(); /** @var $doc Qs_Doc */ $doc = Zend_Registry::get('doc'); $doc->addScript('js/jquery-autoNumeric.js') ->addInitFunction('$("#' . $element->getId() . '").autoNumeric', array($options)); return $this; } protected function _initAppendPrepend() { $element = $this->getElement(); if (!($htmlTag = $element->getDecorator('HtmlTag')) ) { return $this; } $classes = '' . $htmlTag->getOption('class'); $classes = preg_split('/[\s]+/', $classes); $classes = array_filter($classes); foreach (['prepend' => 'BeforeElement', 'append' => 'AfterElement'] as $attribute => $section) { if (!($text = $element->getAttrib($attribute))) { continue; } $classes[] = 'input-' . $attribute; $element->setAttrib($attribute, null); $this->_setAdditionalHtml($section, '' . $text . ''); } $htmlTag->setOption('class', implode(' ', $classes)); return $this; } /** * @param Qs_Form_Element_Numeric $element * @return null|string */ public function getValue($element) { $value = parent::getValue($element); if (null !== $value) { $value = number_format( (float) $value, $element->getPrecision(), $element->getDecimal(), $element->getGroup() ); } return $value; } }