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
10 namespace Zend\Form\Element
;
12 use Zend\Form\Element
;
13 use Zend\Validator\DateStep
as DateStepValidator
;
14 use Zend\Validator\Regex
as RegexValidator
;
15 use Zend\Validator\ValidatorInterface
;
17 class Month
extends DateTime
24 protected $attributes = array(
29 * Retrieves a Date Validator configured for a Month Input type
31 * @return ValidatorInterface
33 protected function getDateValidator()
35 return new RegexValidator('/^[0-9]{4}\-(0[1-9]|1[012])$/');
39 * Retrieves a DateStep Validator configured for a Month Input type
41 * @return ValidatorInterface
43 protected function getStepValidator()
45 $stepValue = (isset($this->attributes
['step']))
46 ?
$this->attributes
['step'] : 1; // Months
48 $baseValue = (isset($this->attributes
['min']))
49 ?
$this->attributes
['min'] : '1970-01';
51 return new DateStepValidator(array(
53 'baseValue' => $baseValue,
54 'step' => new \
DateInterval("P{$stepValue}M"),