Skip to content

Commit

Permalink
Merge pull request #16509 from craftcms/bugfix/readonly-settings-for-…
Browse files Browse the repository at this point in the history
…plugins-only-using-settingsHtml

support read-only settings when plugin only implements settingsHtml()
  • Loading branch information
brandonkelly authored Jan 24, 2025
2 parents ac44768 + 595d819 commit b00aaa7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Added a `cp.login.alternative-login-methods` hook to the system login template.
- Fixed a bug where Color fields’ custom color inputs were including presets based on the color palette.
- Fixed a bug where nested Matrix entries weren’t getting assigned a post date if they were created while saving the owner element with a custom validation scenario. ([#16504](https://github.com/craftcms/cms/pull/16504))
- Fixed a bug where plugin settings pages weren’t displaying a read-only notice and had Save buttons, when `allowAdminChanges` was `false`. ([#16509](https://github.com/craftcms/cms/pull/16509))

## 5.6.1 - 2025-01-22

Expand Down
1 change: 1 addition & 0 deletions src/base/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ private function settingsResponse(bool $readOnly): Response
return $controller->renderTemplate('settings/plugins/_settings.twig', [
'plugin' => $this,
'settingsHtml' => $settingsHtml,
'readOnly' => $readOnly,
]);
}

Expand Down
14 changes: 10 additions & 4 deletions src/templates/settings/plugins/_settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{% extends "_layouts/cp" %}
{% set title = plugin.name %}
{% set docTitle = title ~ ' - ' ~ "Plugins"|t('app') %}
{% set fullPageForm = true %}
{% set readOnly = readOnly ?? false %}
{% set fullPageForm = not readOnly %}

{% set crumbs = [
{ label: "Settings"|t('app'), url: url('settings') },
Expand All @@ -19,10 +20,15 @@
},
] %}

{% if readOnly %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
{{ actionInput('plugins/save-plugin-settings') }}
{{ hiddenInput('pluginHandle', plugin.handle) }}
{{ redirectInput('settings') }}
{% if not readOnly %}
{{ actionInput('plugins/save-plugin-settings') }}
{{ hiddenInput('pluginHandle', plugin.handle) }}
{{ redirectInput('settings') }}
{% endif %}
{{ settingsHtml|raw }}
{% endblock %}

0 comments on commit b00aaa7

Please sign in to comment.