Skip to content

Template field does not follow sync with origin #14534

@webmasterlv

Description

@webmasterlv

Bug description

When using multisite, the template gets desynced from child pages.

How to reproduce

Enable multisite. Add template field to Page's Blueprint:

handle: template
    field:
        type: template
        display: Šablons
        localizable: false
        folder: templates/pages
  1. Create page in origin, save
  2. Switch to another locale, save & publish.

Localized entry data gets populated with template selected in origin, which I guess is fine.
In localized page I cannot change layout, which is fine.

Now, when changing layout in origin page, the localized page data still shows old template:

"template":"templates\/pages\/fullscreen"

If I remove that JSON key/value and save origin, the translated page's data again receives the template, but subsequent changes of origin page layout are not proliferated to child pages.

Logs

Environment

Environment
Laravel Version: 12.56.0
PHP Version: 8.3.30
Composer Version: 2.9.5
Environment: local
Debug Mode: ENABLED
Maintenance Mode: OFF
Timezone: Europe/Riga
Locale: lv

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: null
Cache: file
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Storage
public/storage: LINKED

Statamic
Addons: 6
Sites: 2 (LAT, ENG)
Stache Watcher: Enabled
Static Caching: Disabled
Version: 6.14.0 PRO

Statamic Addons
iagofelicio/geo-maps: 2.3.0
pecotamic/sitemap: 1.4.10
rias/statamic-address-field: 2.0.1
statamic/eloquent-driver: 5.6.3
statamic/importer: 2.1.0
statamic/ssg: 4.1.0

Statamic Eloquent Driver
Addon Settings: file
Asset Containers: file
Assets: file
Blueprints: file
Collection Trees: eloquent
Collections: file
Entries: eloquent
Fieldsets: file
Form Submissions: eloquent
Forms: file
Global Sets: file
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: file
Revisions: file
Sites: file
Taxonomies: file
Terms: eloquent
Tokens: file

Installation

Fresh statamic/statamic site via CLI

Additional details

Gemini suggests this might be related to Eloquent driver, in this case, I will move the issue there.
This is the workaround I use while this is fixed (in AppServiceProvider::boot):

$entryModelClass = config(
	'statamic.eloquent-driver.entries.model',
	\Statamic\Eloquent\Entries\EntryModel::class
);

$entryModelClass::saving(function ($model) {
	if ($model->origin_id && $model->collection === 'pages') {
		$data = $model->data ?? [];

		if (array_key_exists('template', $data)) {
			unset($data['template']);
			$model->data = $data;
		}
	}
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions