File tree Expand file tree Collapse file tree 3 files changed +11
-6
lines changed
Test/Unit/Block/System/Config/Form Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
43
43
$ element ->setDisabled (true );
44
44
}
45
45
46
+ if ($ element ->getIsDisableInheritance ()) {
47
+ $ element ->setReadonly (true );
48
+ }
49
+
46
50
$ html = '<td class="label"><label for=" ' .
47
51
$ element ->getHtmlId () . '"><span ' .
48
52
$ this ->_renderScopeLabel ($ element ) . '> ' .
@@ -94,7 +98,7 @@ protected function _renderInheritCheckbox(\Magento\Framework\Data\Form\Element\A
94
98
$ htmlId = $ element ->getHtmlId ();
95
99
$ namePrefix = preg_replace ('#\[value\](\[\])?$# ' , '' , $ element ->getName ());
96
100
$ checkedHtml = $ element ->getInherit () == 1 ? 'checked="checked" ' : '' ;
97
- $ disabled = $ element ->getIsDisableInheritance () == true ? ' disabled="disabled" ' : '' ;
101
+ $ disabled = $ element ->getIsDisableInheritance () == true ? ' disabled="disabled" readonly="1" ' : '' ;
98
102
99
103
$ html = '<td class="use-default"> ' ;
100
104
$ html .= '<input id=" ' .
Original file line number Diff line number Diff line change 7
7
8
8
/**
9
9
* Test how class render field html element in Stores Configuration
10
- *
11
- * @package Magento\Config\Test\Unit\Block\System\Config\Form
12
10
*/
13
11
class FieldTest extends \PHPUnit \Framework \TestCase
14
12
{
@@ -72,6 +70,7 @@ protected function setUp()
72
70
'getCanUseDefaultValue ' ,
73
71
'setDisabled ' ,
74
72
'getTooltip ' ,
73
+ 'setReadonly '
75
74
]
76
75
);
77
76
@@ -179,15 +178,16 @@ public function testRenderInheritCheckbox()
179
178
$ this ->_elementMock ->expects ($ this ->any ())->method ('getCanUseWebsiteValue ' )->will ($ this ->returnValue (true ));
180
179
$ this ->_elementMock ->expects ($ this ->any ())->method ('getCanUseDefaultValue ' )->will ($ this ->returnValue (true ));
181
180
$ this ->_elementMock ->expects ($ this ->once ())->method ('setDisabled ' )->with (true );
182
- $ this ->_elementMock ->expects ($ this ->once ())->method ('getIsDisableInheritance ' )->willReturn (true );
181
+ $ this ->_elementMock ->method ('getIsDisableInheritance ' )->willReturn (true );
182
+ $ this ->_elementMock ->method ('setReadonly ' )->with (true );
183
183
184
184
$ expected = '<td class="use-default"> ' ;
185
185
$ expected .= '<input id=" ' .
186
186
$ this ->_testData ['htmlId ' ] .
187
187
'_inherit" name=" ' .
188
188
$ this ->_testData ['name ' ] .
189
189
'[inherit]" type="checkbox" value="1" ' .
190
- ' class="checkbox config-inherit" checked="checked" ' . ' disabled="disabled" ' .
190
+ ' class="checkbox config-inherit" checked="checked" ' . ' disabled="disabled" ' . ' readonly="1" ' .
191
191
' onclick="toggleValueElements(this, Element.previous(this.parentNode))" /> ' ;
192
192
193
193
$ expected .= '<label for=" ' . $ this ->_testData ['htmlId ' ] . '_inherit" class="inherit">Use Website</label> ' ;
Original file line number Diff line number Diff line change @@ -494,7 +494,8 @@ define([
494
494
inputs . each ( function ( item ) {
495
495
// don't touch hidden inputs (and Use Default inputs too), bc they may have custom logic
496
496
if ( ( ! item . type || item . type != 'hidden' ) && ! ( $ ( item . id + '_inherit' ) && $ ( item . id + '_inherit' ) . checked ) && //eslint-disable-line
497
- ! ( currentConfig [ 'can_edit_price' ] != undefined && ! currentConfig [ 'can_edit_price' ] ) //eslint-disable-line
497
+ ! ( currentConfig [ 'can_edit_price' ] != undefined && ! currentConfig [ 'can_edit_price' ] ) && //eslint-disable-line
498
+ ! item . getAttribute ( 'readonly' ) //eslint-disable-line
498
499
) {
499
500
item . disabled = false ;
500
501
jQuery ( item ) . removeClass ( 'ignore-validate' ) ;
You can’t perform that action at this time.
0 commit comments