Permalink
Browse files

Use RFC-3339 full-date format (Y-m-d) in Date element

  • Loading branch information...
1 parent 833817e commit 0029ccdc82aad1a7a8fb85bcfaf779fcfd19a124 @weierophinney weierophinney committed Oct 5, 2012
Showing with 18 additions and 0 deletions.
  1. +8 −0 library/Zend/Form/Element/Date.php
  2. +10 −0 tests/ZendTest/Form/Element/DateTest.php
@@ -34,6 +34,14 @@ class Date extends DateTimeElement
);
/**
+ * Date format to use for DateTime values. By default, this is RFC-3339,
+ * full-date (Y-m-d), which is what HTML5 dictates.
+ *
+ * @var string
+ */
+ protected $format = 'Y-m-d';
+
+ /**
* Retrieves a Date Validator configured for a DateTime Input type
*
* @return ValidatorInterface
@@ -10,6 +10,7 @@
namespace ZendTest\Form\Element;
+use DateTime;
use PHPUnit_Framework_TestCase as TestCase;
use Zend\Form\Element\Date as DateElement;
use Zend\Form\Factory;
@@ -85,4 +86,13 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri
}
}
}
+
+ public function testValueReturnedFromComposedDateTimeIsRfc3339FullDateFormat()
+ {
+ $element = new DateElement('foo');
+ $date = new DateTime();
+ $element->setValue($date);
+ $value = $element->getValue();
+ $this->assertEquals($date->format('Y-m-d'), $value);
+ }
}

0 comments on commit 0029ccd

Please sign in to comment.