Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'hotfix/5928' into develop

Close #5928
  • Loading branch information...
commit 08d264ca1a78d62564e0d17cf1dbbc49c1039c0c 2 parents aa809a3 + e7db151
Matthew Weier O'Phinney weierophinney authored
4 library/Zend/Form/Element/DateTimeSelect.php
View
@@ -220,6 +220,10 @@ public function setValue($value)
}
}
+ if (is_null($value)) {
+ $value = new PhpDateTime();
+ }
+
if ($value instanceof PhpDateTime) {
$value = array(
'year' => $value->format('Y'),
13 tests/ZendTest/Form/Element/DateTimeSelectTest.php
View
@@ -137,4 +137,17 @@ public function testCloningPreservesCorrectValues()
$this->assertEquals('04', $cloned->getMinuteElement()->getValue());
$this->assertEquals('05', $cloned->getSecondElement()->getValue());
}
+
+ public function testPassingNullValueToSetValueWillUseCurrentDate()
+ {
+ $now = new DateTime;
+ $element = new DateTimeSelectElement();
+ $element->setValue(null);
+ $yearElement = $element->getYearElement();
+ $monthElement = $element->getMonthElement();
+ $dayElement = $element->getDayElement();
+ $this->assertEquals($now->format('Y'), $yearElement->getValue());
+ $this->assertEquals($now->format('m'), $monthElement->getValue());
+ $this->assertEquals($now->format('d'), $dayElement->getValue());
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.