Skip to content

Commit

Permalink
Fix config override notices
Browse files Browse the repository at this point in the history
  • Loading branch information
mgburns committed Sep 19, 2018
1 parent 42bbb0b commit 7630522
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/UserManual.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,14 @@ protected function settingsHtml(): string
];
}

// Get override settings from config file.
$overrides = Craft::$app->getConfig()->getConfigFromFile(strtolower($this->handle));

return Craft::$app->view->renderTemplate(
'usermanual/settings',
[
'settings' => $this->getSettings(),
'overrides' => array_keys($overrides),
'options' => $options,
'siteTemplatesPath' => Craft::$app->getPath()->getSiteTemplatesPath(),
]
Expand Down
10 changes: 5 additions & 5 deletions src/templates/settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

{% from _self import configWarning %}

{% set configOverride = craft.config.get('pluginNameOverride', 'usermanual') is not null %}
{% set configOverride = 'pluginNameOverride' in overrides %}
{{ forms.textField({
label: "Plugin Name"|t,
id: 'pluginNameOverride',
Expand All @@ -38,7 +38,7 @@
readonly: configOverride,
})}}

{% set configOverride = craft.config.get('section', 'usermanual') is not null %}
{% set configOverride = 'section' in overrides %}
{% set inputMacro = configOverride ? 'textField' : 'selectField' %}
{% set opts = {
label: "User Manual Section"|t,
Expand All @@ -47,7 +47,7 @@
instructions: 'Entries in this section must have associated urls.'|t,
value: settings.section,
options: options,
warning: configOverride ? configWarning('pluginNameOverride'),
warning: configOverride ? configWarning('section'),
disabled: configOverride,
readonly: configOverride,
} %}
Expand All @@ -57,7 +57,7 @@
For more control over the output, you may optionally override the default template.<br>
Path is relative to <code>{{ siteTemplatesPath }}</code>.
{% endset %}
{% set configOverride = craft.config.get('templateOverride', 'usermanual') is not null %}
{% set configOverride = 'templateOverride' in overrides %}

{{ forms.textField({
label: "Template Override"|t,
Expand All @@ -67,7 +67,7 @@ Path is relative to <code>{{ siteTemplatesPath }}</code>.
instructions: instructions|raw,
value: settings.templateOverride,
errors: '',
warning: configOverride ? configWarning('pluginNameOverride'),
warning: configOverride ? configWarning('templateOverride'),
disabled: configOverride,
readonly: configOverride,
})}}

0 comments on commit 7630522

Please sign in to comment.