Skip to content

Commit 116da89

Browse files
author
Pascal Querner
committed
feat: set disabled, set scope label
1 parent e50cf57 commit 116da89

File tree

1 file changed

+14
-7
lines changed
  • app/code/core/Mage/Adminhtml/Block/System/Config

1 file changed

+14
-7
lines changed

app/code/core/Mage/Adminhtml/Block/System/Config/Form.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Mage_Adminhtml_Block_System_Config_Form extends Mage_Adminhtml_Block_Widge
1717
public const SCOPE_DEFAULT = 'default';
1818
public const SCOPE_WEBSITES = 'websites';
1919
public const SCOPE_STORES = 'stores';
20+
public const SCOPE_ENV = 'env';
2021

2122
/**
2223
* Config data array
@@ -71,6 +72,7 @@ public function __construct()
7172
self::SCOPE_DEFAULT => Mage::helper('adminhtml')->__('[GLOBAL]'),
7273
self::SCOPE_WEBSITES => Mage::helper('adminhtml')->__('[WEBSITE]'),
7374
self::SCOPE_STORES => Mage::helper('adminhtml')->__('[STORE VIEW]'),
75+
self::SCOPE_ENV => Mage::helper('adminhtml')->__('[ENV]'),
7476
];
7577
}
7678

@@ -368,11 +370,10 @@ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labe
368370
}
369371
}
370372

371-
$field = $fieldset->addField($id, $fieldType, [
373+
$elementFieldData = [
372374
'name' => $name,
373375
'label' => $label,
374376
'comment' => $comment,
375-
'disabled' => $this->isDisabled($path),
376377
'tooltip' => $tooltip,
377378
'hint' => $hint,
378379
'value' => $data,
@@ -383,9 +384,14 @@ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labe
383384
'scope' => $this->getScope(),
384385
'scope_id' => $this->getScopeId(),
385386
'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);
389395
$this->_prepareFieldOriginalData($field, $element);
390396

391397
if (isset($element->validate)) {
@@ -624,9 +630,10 @@ public function getScope()
624630
}
625631

626632
/**
627-
* Render element as disabled, if overwritten by ENV variable
633+
* Returns true if element was overwritten by ENV variable
634+
* @return bool
628635
*/
629-
public function isDisabled(string $path): bool
636+
public function isOverwrittenByEnvVariable(string $path): bool
630637
{
631638
/** @var Mage_Core_Helper_EnvironmentConfigLoader $environmentConfigLoaderHelper */
632639
$environmentConfigLoaderHelper = Mage::helper('core/environmentConfigLoader');

0 commit comments

Comments
 (0)