Skip to content

Commit

Permalink
Merge pull request magento#3554 from magento-chaika/chaika_december
Browse files Browse the repository at this point in the history
[chaika] MAGETWO-96845: [2.3.x] Attribute page not loaded if set default value
  • Loading branch information
Lysenko Olexandr authored Dec 27, 2018
2 parents d88cf06 + 850c674 commit 2b27bc0
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/internal/Magento/Framework/Data/Form/Element/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
*
* @author Magento Core Team <core@magentocommerce.com>
*/

namespace Magento\Framework\Data\Form\Element;

use Magento\Framework\Escaper;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;

/**
* Date element
*/
class Date extends AbstractElement
{
/**
Expand Down Expand Up @@ -50,8 +54,7 @@ public function __construct(
}

/**
* If script executes on x64 system, converts large
* numeric values to timestamp limit
* If script executes on x64 system, converts large numeric values to timestamp limit
*
* @param int $value
* @return int
Expand Down Expand Up @@ -82,13 +85,14 @@ public function setValue($value)
$this->_value = $value;
return $this;
}
if (preg_match('/^[0-9]+$/', $value)) {
$this->_value = (new \DateTime())->setTimestamp($this->_toTimestamp($value));
return $this;
}

try {
$this->_value = new \DateTime($value, new \DateTimeZone($this->localeDate->getConfigTimezone()));
if (preg_match('/^[0-9]+$/', $value)) {
$this->_value = (new \DateTime())->setTimestamp($this->_toTimestamp($value));
} else {
$this->_value = new \DateTime($value);
$this->_value->setTimezone(new \DateTimeZone($this->localeDate->getConfigTimezone()));
}
} catch (\Exception $e) {
$this->_value = '';
}
Expand All @@ -97,6 +101,7 @@ public function setValue($value)

/**
* Get date value as string.
*
* Format can be specified, or it will be taken from $this->getFormat()
*
* @param string $format (compatible with \DateTime)
Expand Down

0 comments on commit 2b27bc0

Please sign in to comment.