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
4343 $ element ->setDisabled (true );
4444 }
4545
46+ if ($ element ->getIsDisableInheritance ()) {
47+ $ element ->setReadonly (true );
48+ }
49+
4650 $ html = '<td class="label"><label for=" ' .
4751 $ element ->getHtmlId () . '"><span ' .
4852 $ this ->_renderScopeLabel ($ element ) . '> ' .
@@ -94,7 +98,7 @@ protected function _renderInheritCheckbox(\Magento\Framework\Data\Form\Element\A
9498 $ htmlId = $ element ->getHtmlId ();
9599 $ namePrefix = preg_replace ('#\[value\](\[\])?$# ' , '' , $ element ->getName ());
96100 $ checkedHtml = $ element ->getInherit () == 1 ? 'checked="checked" ' : '' ;
97- $ disabled = $ element ->getIsDisableInheritance () == true ? ' disabled="disabled" ' : '' ;
101+ $ disabled = $ element ->getIsDisableInheritance () == true ? ' disabled="disabled" readonly="1" ' : '' ;
98102
99103 $ html = '<td class="use-default"> ' ;
100104 $ html .= '<input id=" ' .
Original file line number Diff line number Diff line change 77
88/**
99 * Test how class render field html element in Stores Configuration
10- *
11- * @package Magento\Config\Test\Unit\Block\System\Config\Form
1210 */
1311class FieldTest extends \PHPUnit \Framework \TestCase
1412{
@@ -72,6 +70,7 @@ protected function setUp()
7270 'getCanUseDefaultValue ' ,
7371 'setDisabled ' ,
7472 'getTooltip ' ,
73+ 'setReadonly '
7574 ]
7675 );
7776
@@ -179,15 +178,16 @@ public function testRenderInheritCheckbox()
179178 $ this ->_elementMock ->expects ($ this ->any ())->method ('getCanUseWebsiteValue ' )->will ($ this ->returnValue (true ));
180179 $ this ->_elementMock ->expects ($ this ->any ())->method ('getCanUseDefaultValue ' )->will ($ this ->returnValue (true ));
181180 $ 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 );
183183
184184 $ expected = '<td class="use-default"> ' ;
185185 $ expected .= '<input id=" ' .
186186 $ this ->_testData ['htmlId ' ] .
187187 '_inherit" name=" ' .
188188 $ this ->_testData ['name ' ] .
189189 '[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" ' .
191191 ' onclick="toggleValueElements(this, Element.previous(this.parentNode))" /> ' ;
192192
193193 $ 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([
494494 inputs . each ( function ( item ) {
495495 // don't touch hidden inputs (and Use Default inputs too), bc they may have custom logic
496496 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
498499 ) {
499500 item . disabled = false ;
500501 jQuery ( item ) . removeClass ( 'ignore-validate' ) ;
You can’t perform that action at this time.
0 commit comments