@@ -134,6 +134,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
134
134
* @param \Magento\Config\Block\System\Config\Form\Fieldset\Factory $fieldsetFactory
135
135
* @param \Magento\Config\Block\System\Config\Form\Field\Factory $fieldFactory
136
136
* @param array $data
137
+ * @param SettingChecker|null $settingChecker
137
138
*/
138
139
public function __construct (
139
140
\Magento \Backend \Block \Template \Context $ context ,
@@ -143,13 +144,15 @@ public function __construct(
143
144
\Magento \Config \Model \Config \Structure $ configStructure ,
144
145
\Magento \Config \Block \System \Config \Form \Fieldset \Factory $ fieldsetFactory ,
145
146
\Magento \Config \Block \System \Config \Form \Field \Factory $ fieldFactory ,
146
- array $ data = []
147
+ array $ data = [],
148
+ SettingChecker $ settingChecker = null
147
149
) {
148
150
parent ::__construct ($ context , $ registry , $ formFactory , $ data );
149
151
$ this ->_configFactory = $ configFactory ;
150
152
$ this ->_configStructure = $ configStructure ;
151
153
$ this ->_fieldsetFactory = $ fieldsetFactory ;
152
154
$ this ->_fieldFactory = $ fieldFactory ;
155
+ $ this ->settingChecker = $ settingChecker ?: ObjectManager::getInstance ()->get (SettingChecker::class);
153
156
154
157
$ this ->_scopeLabels = [
155
158
self ::SCOPE_DEFAULT => __ ('[GLOBAL] ' ),
@@ -366,9 +369,8 @@ protected function _initElement(
366
369
367
370
$ sharedClass = $ this ->_getSharedCssClass ($ field );
368
371
$ requiresClass = $ this ->_getRequiresCssClass ($ field , $ fieldPrefix );
372
+ $ isReadOnly = $ this ->getReadOnly ($ field , $ path );
369
373
370
- $ isReadOnly = $ this ->getElementVisibility ()->isDisabled ($ field ->getPath ())
371
- ?: $ this ->getSettingChecker ()->isReadOnly ($ path , $ this ->getScope (), $ this ->getStringScopeCode ());
372
374
$ formField = $ fieldset ->addField (
373
375
$ elementId ,
374
376
$ field ->getType (),
@@ -417,7 +419,7 @@ private function getFieldData(\Magento\Config\Model\Config\Structure\Element\Fie
417
419
{
418
420
$ data = $ this ->getAppConfigDataValue ($ path );
419
421
420
- $ placeholderValue = $ this ->getSettingChecker () ->getPlaceholderValue (
422
+ $ placeholderValue = $ this ->settingChecker ->getPlaceholderValue (
421
423
$ path ,
422
424
$ this ->getScope (),
423
425
$ this ->getStringScopeCode ()
@@ -797,6 +799,25 @@ private function getAppConfig()
797
799
return $ this ->appConfig ;
798
800
}
799
801
802
+ /**
803
+ * Check Path is Readonly
804
+ *
805
+ * @param \Magento\Config\Model\Config\Structure\Element\Field $field
806
+ * @param string $path
807
+ * @return boolean
808
+ */
809
+ private function getReadOnly (\Magento \Config \Model \Config \Structure \Element \Field $ field , $ path )
810
+ {
811
+ $ isReadOnly = $ this ->settingChecker ->isReadOnly (
812
+ $ path , ScopeConfigInterface::SCOPE_TYPE_DEFAULT
813
+ );
814
+ if (!$ isReadOnly ) {
815
+ $ isReadOnly = $ this ->getElementVisibility ()->isDisabled ($ field ->getPath ())
816
+ ?: $ this ->settingChecker ->isReadOnly ($ path , $ this ->getScope (), $ this ->getStringScopeCode ());
817
+ }
818
+ return $ isReadOnly ;
819
+ }
820
+
800
821
/**
801
822
* Retrieve deployment config data value by path
802
823
*
0 commit comments