@@ -17,6 +17,7 @@ class Mage_Adminhtml_Block_System_Config_Form extends Mage_Adminhtml_Block_Widge
17
17
public const SCOPE_DEFAULT = 'default ' ;
18
18
public const SCOPE_WEBSITES = 'websites ' ;
19
19
public const SCOPE_STORES = 'stores ' ;
20
+ public const SCOPE_ENV = 'env ' ;
20
21
21
22
/**
22
23
* Config data array
@@ -71,6 +72,7 @@ public function __construct()
71
72
self ::SCOPE_DEFAULT => Mage::helper ('adminhtml ' )->__ ('[GLOBAL] ' ),
72
73
self ::SCOPE_WEBSITES => Mage::helper ('adminhtml ' )->__ ('[WEBSITE] ' ),
73
74
self ::SCOPE_STORES => Mage::helper ('adminhtml ' )->__ ('[STORE VIEW] ' ),
75
+ self ::SCOPE_ENV => Mage::helper ('adminhtml ' )->__ ('[ENV] ' ),
74
76
];
75
77
}
76
78
@@ -368,11 +370,10 @@ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labe
368
370
}
369
371
}
370
372
371
- $ field = $ fieldset -> addField ( $ id , $ fieldType , [
373
+ $ elementFieldData = [
372
374
'name ' => $ name ,
373
375
'label ' => $ label ,
374
376
'comment ' => $ comment ,
375
- 'disabled ' => $ this ->isDisabled ($ path ),
376
377
'tooltip ' => $ tooltip ,
377
378
'hint ' => $ hint ,
378
379
'value ' => $ data ,
@@ -383,9 +384,14 @@ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labe
383
384
'scope ' => $ this ->getScope (),
384
385
'scope_id ' => $ this ->getScopeId (),
385
386
'scope_label ' => $ this ->getScopeLabel ($ element ),
386
- 'can_use_default_value ' => $ this ->canUseDefaultValue ((int ) $ element ->show_in_default ),
387
- 'can_use_website_value ' => $ this ->canUseWebsiteValue ((int ) $ element ->show_in_website ),
388
- ]);
387
+ 'can_use_default_value ' => $ this ->canUseDefaultValue ((int )$ element ->show_in_default ),
388
+ 'can_use_website_value ' => $ this ->canUseWebsiteValue ((int )$ element ->show_in_website ),
389
+ ];
390
+ if ($ this ->isOverwrittenByEnvVariable ($ path )) {
391
+ $ elementFieldData ['scope_label ' ] = $ this ->_scopeLabels [static ::SCOPE_ENV ];
392
+ $ elementFieldData ['disabled ' ] = 1 ;
393
+ }
394
+ $ field = $ fieldset ->addField ($ id , $ fieldType , $ elementFieldData );
389
395
$ this ->_prepareFieldOriginalData ($ field , $ element );
390
396
391
397
if (isset ($ element ->validate )) {
@@ -624,9 +630,10 @@ public function getScope()
624
630
}
625
631
626
632
/**
627
- * Render element as disabled, if overwritten by ENV variable
633
+ * Returns true if element was overwritten by ENV variable
634
+ * @return bool
628
635
*/
629
- public function isDisabled (string $ path ): bool
636
+ public function isOverwrittenByEnvVariable (string $ path ): bool
630
637
{
631
638
/** @var Mage_Core_Helper_EnvironmentConfigLoader $environmentConfigLoaderHelper */
632
639
$ environmentConfigLoaderHelper = Mage::helper ('core/environmentConfigLoader ' );
0 commit comments