-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3554 from magento-chaika/chaika_december
[chaika] MAGETWO-96845: [2.3.x] Attribute page not loaded if set default value
- Loading branch information
Showing
1 changed file
with
12 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,15 @@ | |
* | ||
* @author Magento Core Team <[email protected]> | ||
*/ | ||
|
||
namespace Magento\Framework\Data\Form\Element; | ||
|
||
use Magento\Framework\Escaper; | ||
use Magento\Framework\Stdlib\DateTime\TimezoneInterface; | ||
|
||
/** | ||
* Date element | ||
*/ | ||
class Date extends AbstractElement | ||
{ | ||
/** | ||
|
@@ -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 | ||
|
@@ -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 = ''; | ||
} | ||
|
@@ -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) | ||
|