* @copyright 2010, Enrise * @license http://www.opensource.org/licenses/bsd-license.php * @version $Id: $ */ /** * Base class for HTML5 number element * * @category Glitch * @package Glitch_Form * @subpackage Element */ class Glitch_Form_Element_Text_Number extends Glitch_Form_Element_Text { /** * Initialize additional element options * * @return Glitch_Form_Element_Text_Email */ public function init() { if ($this->isAutoloadFilters()) { $this->addFilter('Digits'); } if ($this->isAutoloadValidators()) { $this->addValidator('Digits'); $validatorOpts = array_filter(array( 'min' => $this->getAttrib('min'), 'max' => $this->getAttrib('max'), )); $validator = null; if (2 === count($validatorOpts)) { $validator = 'Between'; } else if (isset($validatorOpts['min'])) { $validator = 'GreaterThan'; } else if (isset($validatorOpts['max'])) { $validator = 'LessThan'; } if (null !== $validator) { $this->addValidator($validator, false, $validatorOpts); } } return $this; } }