123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- /**
- *
- * PHP Pro Bid $Id$ YiS2qE8mFFUB1lpn9ufd2/gZfLszl9WpY+Szb5+Qd34=
- *
- * @link http://www.phpprobid.com
- * @copyright Copyright (c) 2016 Online Ventures Software & CodeCube SRL
- * @license http://www.phpprobid.com/license Commercial License
- *
- * @version 7.8
- */
- /**
- * localized number input element
- * the format and decimals are set automatically by the locale format instance
- * - highly recommended to use the localized numeric filter together with this element
- * OR
- * - when saving in the database, the value from the field needs to be
- * formatted with the Cube\Locale\Format::localizedToNumeric() method
- */
- namespace Ppb\Form\Element;
- use Cube\Form\Element,
- Cube\Locale\Format as LocaleFormat;
- class LocalizedNumeric extends Element
- {
- /**
- *
- * type of element - override the variable from the parent class
- *
- * @var string
- */
- protected $_element = 'text';
- /**
- *
- * class constructor
- *
- * @param string $name
- */
- public function __construct($name)
- {
- parent::__construct($this->_element, $name);
- }
- /**
- *
- * renders the html form element
- *
- * @return string the html code of the element
- */
- public function render()
- {
- $value = $this->getValue();
- $localizedValue = LocaleFormat::getInstance()->numericToLocalized($value, true);
- $multiple = ($this->getMultiple() === true) ? $this->_brackets : '';
- return $this->getPrefix() . ' '
- . '<input type="' . $this->_type . '" '
- . 'name="' . $this->_name . $multiple . '" '
- . $this->renderAttributes()
- . 'value="' . $localizedValue . '" '
- . $this->_endTag . ' '
- . $this->getSuffix();
- }
- }
|