Skip to content

Commit 6c87bb3

Browse files
author
Vasilii Burlacu
committed
magento/magento2:#4136 - Widget condition with unexpected character not preventing from saving
- Restricted user to change date input value - Open datepicker popup once user click on the date to be changed
1 parent ff4b005 commit 6c87bb3

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

app/code/Magento/Rule/Model/Condition/AbstractCondition.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@ public function getValueElement()
630630
// date format intentionally hard-coded
631631
$elementParams['input_format'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
632632
$elementParams['date_format'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
633+
$elementParams['placeholder'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
634+
$elementParams['autocomplete'] = 'off';
635+
$elementParams['readonly'] = 'true';
633636
}
634637
return $this->getForm()->addField(
635638
$this->getPrefix() . '__' . $this->getId() . '__value',

app/design/adminhtml/Magento/backend/web/css/styles-old.less

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,6 +3840,26 @@
38403840

38413841
.rule-param-edit .element {
38423842
display: inline;
3843+
position: relative;
3844+
}
3845+
3846+
.rule-param-edit .element input.input-date,
3847+
.rule-param-edit .element input.input-date[readonly] {
3848+
background-color: @color-white;
3849+
min-width: 140px;
3850+
width: 140px !important;
3851+
cursor: pointer;
3852+
text-align: center;
3853+
opacity: 1;
3854+
margin-right: 10px;
3855+
padding-right: 40px;
3856+
3857+
+ .ui-datepicker-trigger {
3858+
position: absolute;
3859+
width: 140px;
3860+
text-align: right;
3861+
left: 0;
3862+
}
38433863
}
38443864

38453865
.rule-param-edit .element .addafter {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ public function getHtmlAttributes()
238238
'onchange',
239239
'disabled',
240240
'readonly',
241+
'autocomplete',
241242
'tabindex',
242243
'placeholder',
243244
'data-form-part',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function getValueInstance()
147147
*/
148148
public function getElementHtml()
149149
{
150-
$this->addClass('admin__control-text input-text');
150+
$this->addClass('admin__control-text input-text input-date');
151151
$dateFormat = $this->getDateFormat() ?: $this->getFormat();
152152
$timeFormat = $this->getTimeFormat();
153153
if (empty($dateFormat)) {

lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/AbstractElementTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public function testGetHtmlAttributes()
195195
'onchange',
196196
'disabled',
197197
'readonly',
198+
'autocomplete',
198199
'tabindex',
199200
'placeholder',
200201
'data-form-part',

lib/web/mage/calendar.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,6 @@
378378
.text('') // Remove jQuery UI datepicker generated image
379379
.append('<span>' + pickerButtonText + '</span>');
380380

381-
$(element).attr('autocomplete', 'off');
382-
383381
this._setCurrentDate(element);
384382
},
385383

0 commit comments

Comments
 (0)