Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Form / Element / Number.php
blobeb7a45cb2897060af31260416f5b97e2172de943
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Form\Element;
12 use Zend\Form\Element;
13 use Zend\I18n\Validator\Float as NumberValidator;
14 use Zend\InputFilter\InputProviderInterface;
15 use Zend\Validator\GreaterThan as GreaterThanValidator;
16 use Zend\Validator\LessThan as LessThanValidator;
17 use Zend\Validator\Step as StepValidator;
19 class Number extends Element implements InputProviderInterface
21 /**
22 * Seed attributes
24 * @var array
26 protected $attributes = array(
27 'type' => 'number',
30 /**
31 * @var array
33 protected $validators;
35 /**
36 * Get validator
38 * @return \Zend\Validator\ValidatorInterface[]
40 protected function getValidators()
42 if ($this->validators) {
43 return $this->validators;
46 $validators = array();
47 $validators[] = new NumberValidator(array(
48 'locale' => 'en_US', // HTML5 uses "100.01" format
49 ));
51 $inclusive = true;
52 if (!empty($this->attributes['inclusive'])) {
53 $inclusive = $this->attributes['inclusive'];
56 if (isset($this->attributes['min'])) {
57 $validators[] = new GreaterThanValidator(array(
58 'min' => $this->attributes['min'],
59 'inclusive' => $inclusive
60 ));
62 if (isset($this->attributes['max'])) {
63 $validators[] = new LessThanValidator(array(
64 'max' => $this->attributes['max'],
65 'inclusive' => $inclusive
66 ));
69 if (!isset($this->attributes['step'])
70 || 'any' !== $this->attributes['step']
71 ) {
72 $validators[] = new StepValidator(array(
73 'baseValue' => (isset($this->attributes['min'])) ? $this->attributes['min'] : 0,
74 'step' => (isset($this->attributes['step'])) ? $this->attributes['step'] : 1,
75 ));
78 $this->validators = $validators;
79 return $this->validators;
82 /**
83 * Provide default input rules for this element
85 * Attaches a number validator, as well as a greater than and less than validators
87 * @return array
89 public function getInputSpecification()
91 return array(
92 'name' => $this->getName(),
93 'required' => true,
94 'filters' => array(
95 array('name' => 'Zend\Filter\StringTrim')
97 'validators' => $this->getValidators(),