Skip to content

Commit

Permalink
magento/magento2:#4136 - Widget condition with unexpected character n…
Browse files Browse the repository at this point in the history
…ot preventing from saving

- Restricted user to change date input value
- Open datepicker popup once user click on the date to be changed
  • Loading branch information
Vasilii Burlacu committed Nov 8, 2018
1 parent ff4b005 commit 6c87bb3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/code/Magento/Rule/Model/Condition/AbstractCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ public function getValueElement()
// date format intentionally hard-coded
$elementParams['input_format'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
$elementParams['date_format'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
$elementParams['placeholder'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
$elementParams['autocomplete'] = 'off';
$elementParams['readonly'] = 'true';
}
return $this->getForm()->addField(
$this->getPrefix() . '__' . $this->getId() . '__value',
Expand Down
20 changes: 20 additions & 0 deletions app/design/adminhtml/Magento/backend/web/css/styles-old.less
Original file line number Diff line number Diff line change
Expand Up @@ -3840,6 +3840,26 @@

.rule-param-edit .element {
display: inline;
position: relative;
}

.rule-param-edit .element input.input-date,
.rule-param-edit .element input.input-date[readonly] {
background-color: @color-white;
min-width: 140px;
width: 140px !important;
cursor: pointer;
text-align: center;
opacity: 1;
margin-right: 10px;
padding-right: 40px;

+ .ui-datepicker-trigger {
position: absolute;
width: 140px;
text-align: right;
left: 0;
}
}

.rule-param-edit .element .addafter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ public function getHtmlAttributes()
'onchange',
'disabled',
'readonly',
'autocomplete',
'tabindex',
'placeholder',
'data-form-part',
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Data/Form/Element/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function getValueInstance()
*/
public function getElementHtml()
{
$this->addClass('admin__control-text input-text');
$this->addClass('admin__control-text input-text input-date');
$dateFormat = $this->getDateFormat() ?: $this->getFormat();
$timeFormat = $this->getTimeFormat();
if (empty($dateFormat)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public function testGetHtmlAttributes()
'onchange',
'disabled',
'readonly',
'autocomplete',
'tabindex',
'placeholder',
'data-form-part',
Expand Down
2 changes: 0 additions & 2 deletions lib/web/mage/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,6 @@
.text('') // Remove jQuery UI datepicker generated image
.append('<span>' + pickerButtonText + '</span>');

$(element).attr('autocomplete', 'off');

this._setCurrentDate(element);
},

Expand Down

0 comments on commit 6c87bb3

Please sign in to comment.