Skip to content

Commit 2b27bc0

Browse files
author
Lysenko Olexandr
authored
Merge pull request #3554 from magento-chaika/chaika_december
[chaika] MAGETWO-96845: [2.3.x] Attribute page not loaded if set default value
2 parents d88cf06 + 850c674 commit 2b27bc0

File tree

1 file changed

+12
-7
lines changed
  • lib/internal/Magento/Framework/Data/Form/Element

1 file changed

+12
-7
lines changed

lib/internal/Magento/Framework/Data/Form/Element/Date.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99
*
1010
* @author Magento Core Team <[email protected]>
1111
*/
12+
1213
namespace Magento\Framework\Data\Form\Element;
1314

1415
use Magento\Framework\Escaper;
1516
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1617

18+
/**
19+
* Date element
20+
*/
1721
class Date extends AbstractElement
1822
{
1923
/**
@@ -50,8 +54,7 @@ public function __construct(
5054
}
5155

5256
/**
53-
* If script executes on x64 system, converts large
54-
* numeric values to timestamp limit
57+
* If script executes on x64 system, converts large numeric values to timestamp limit
5558
*
5659
* @param int $value
5760
* @return int
@@ -82,13 +85,14 @@ public function setValue($value)
8285
$this->_value = $value;
8386
return $this;
8487
}
85-
if (preg_match('/^[0-9]+$/', $value)) {
86-
$this->_value = (new \DateTime())->setTimestamp($this->_toTimestamp($value));
87-
return $this;
88-
}
8988

9089
try {
91-
$this->_value = new \DateTime($value, new \DateTimeZone($this->localeDate->getConfigTimezone()));
90+
if (preg_match('/^[0-9]+$/', $value)) {
91+
$this->_value = (new \DateTime())->setTimestamp($this->_toTimestamp($value));
92+
} else {
93+
$this->_value = new \DateTime($value);
94+
$this->_value->setTimezone(new \DateTimeZone($this->localeDate->getConfigTimezone()));
95+
}
9296
} catch (\Exception $e) {
9397
$this->_value = '';
9498
}
@@ -97,6 +101,7 @@ public function setValue($value)
97101

98102
/**
99103
* Get date value as string.
104+
*
100105
* Format can be specified, or it will be taken from $this->getFormat()
101106
*
102107
* @param string $format (compatible with \DateTime)

0 commit comments

Comments
 (0)