addScript('js/jquery-autoNumeric.js'); } public function render($content) { $this->_addResources(); return parent::render($content); } protected function _addResources() { /** @var $element Qs_Form_Element_Numeric */ $element = $this->getElement(); $options = [ 'mDec' => $element->getPrecision(), 'aNeg' => ($element->getNegative()) ? '-' : '', 'aSep' => $element->getGroup(), 'aDec' => $element->getDecimal(), 'mNum' => $element->getLength(), ]; /** @var $doc Qs_Doc */ $doc = Zend_Registry::get('doc'); $doc->addScripts($this->getScripts()) ->addInitFunction('$("#' . $element->getId() . '").autoNumeric', [$options]); 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; } }