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
;
13 use Zend\Form\Element
;
14 use Zend\Form\Element\DateTime
as DateTimeElement
;
15 use Zend\Validator\Date
as DateValidator
;
16 use Zend\Validator\DateStep
as DateStepValidator
;
18 class Date
extends DateTimeElement
25 protected $attributes = array(
30 * Date format to use for DateTime values. By default, this is RFC-3339,
31 * full-date (Y-m-d), which is what HTML5 dictates.
35 protected $format = 'Y-m-d';
38 * Retrieves a DateStep Validator configured for a Date Input type
40 * @return \Zend\Validator\ValidatorInterface
42 protected function getStepValidator()
44 $format = $this->getFormat();
45 $stepValue = (isset($this->attributes
['step']))
46 ?
$this->attributes
['step'] : 1; // Days
48 $baseValue = (isset($this->attributes
['min']))
49 ?
$this->attributes
['min'] : date($format, 0);
51 return new DateStepValidator(array(
53 'baseValue' => $baseValue,
54 'step' => new DateInterval("P{$stepValue}D"),