Skip to content

Commit 9544b57

Browse files
committed
Always refresh Template UI elements
Resolves #16837
1 parent 5aff92b commit 9544b57

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

CHANGELOG-WIP.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
- Added the “JSON” field type. ([#16809](https://github.com/craftcms/cms/pull/16809))
2121
- Added “Icon” and “Color” settings to Checkboxes, Dropdown, Multi-select, and Radio Buttons field options. ([#16645](https://github.com/craftcms/cms/pull/16645))
2222
- Added an optional “Download” advanced field to Link fields. ([#16844](https://github.com/craftcms/cms/pull/16844))
23-
- Added support for read-only custom fields, via new “Editability Conditions” on custom fields’ field layout settings. ([#16805](https://github.com/craftcms/cms/pull/16805))
23+
- Added support for read-only custom fields, via new “Editability Conditions” on custom fields’ field layout settings. ([#16805](https://github.com/craftcms/cms/pull/16805))
24+
- “Template” field layout UI elements are now re-rendered on each autosave. ([#16837](https://github.com/craftcms/cms/discussions/16837))
2425
- The email settings page now shows a “Test” button when `allowAdminChanges` is disabled. ([#16508](https://github.com/craftcms/cms/discussions/16508))
2526
- Entry type chips within entry type select inputs now link to their full settings pages. ([#16838](https://github.com/craftcms/cms/pull/16838))
2627
- Double-clicking on entry type chips within entry type select inputs now opens the entry type’s settings in a slideout, rather than its override settings. ([#16838](https://github.com/craftcms/cms/pull/16838))
@@ -55,6 +56,7 @@
5556
- Added `craft\base\FieldInterface::serializeValueForDb()`.
5657
- Added `craft\base\FieldLayoutComponent::conditionalSettingsHtml()`.
5758
- Added `craft\base\FieldLayoutComponent::normalizeCondition()`.
59+
- Added `craft\base\FieldLayoutElement::alwaysRefresh()`.
5860
- Added `craft\base\FieldTrait::$static`.
5961
- Added `craft\db\Table::BULKOPEVENTS`.
6062
- Added `craft\db\Table::SEARCHINDEXQUEUE_FIELDS`.

src/base/FieldLayoutElement.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ abstract public function selectorHtml(): string;
8383
*/
8484
abstract public function formHtml(?ElementInterface $element = null, bool $static = false): ?string;
8585

86+
/**
87+
* Returns whether the layout element should always be re-rendered, even if it’s already included in the form.
88+
*
89+
* @return bool
90+
* @since 5.7.0
91+
*/
92+
public function alwaysRefresh(): bool
93+
{
94+
return false;
95+
}
96+
8697
/**
8798
* Returns the element container HTML attributes.
8899
*

src/fieldlayoutelements/Template.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ public function formHtml(?ElementInterface $element = null, bool $static = false
149149
return Html::tag('div', $content, $this->containerAttributes($element, $static));
150150
}
151151

152+
/**
153+
* @inheritdoc
154+
*/
155+
public function alwaysRefresh(): bool
156+
{
157+
return true;
158+
}
159+
152160
/**
153161
* Renders an error message.
154162
*

src/models/FieldLayout.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ public function createForm(?ElementInterface $element = null, bool $static = fal
10201020
if ($showTab && (!$isConditional || $layoutElement->showInForm($element))) {
10211021
// If it was already included and we just need the missing elements, only keep track that it’s still included
10221022
if (
1023+
!$layoutElement->alwaysRefresh() &&
10231024
$visibleElements !== null &&
10241025
(!$isConditional || (isset($visibleElements[$tab->uid]) && in_array($layoutElement->uid, $visibleElements[$tab->uid])))
10251026
) {

0 commit comments

Comments
 (0)