Skip to content

Store the default layout when saving a new static page - #555

Merged
daftspunk merged 1 commit into
rainlab:masterfrom
DonnyOexman:fix/persist-default-layout
Nov 14, 2026
Merged

daftspunk merged 1 commit into
rainlab:masterfrom
DonnyOexman:fix/persist-default-layout

Conversation

@DonnyOexman

Copy link
Copy Markdown
Contributor

Problem

A new page saved in the v3 editor without choosing a layout gets no layout in its file. setDefaultLayout() runs after fill() and only updates the view bag component, while the file is written from the viewBag attribute.

Without a stored layout, getLayoutObject() falls back to the first layout from Layout::listInTheme(). That order comes from RecursiveDirectoryIterator and depends on the filesystem: alphabetical on macOS, unordered on Linux (ext4). On a Linux server a new page can end up on another layout (e.g. error.htm). The save response still uses the in-memory layout, so the editor shows the syntax tab, but the island loads the page from disk and renders none of its fields.

Fix

Resolve the default layout before fill() and add it to the posted settings, so it is written to the page file, like pages created with v2.

Test

Added NewPageLayoutTest. It fails without the fix (layout is null); with the fix the full suite passes (85 tests).

Steps to reproduce

  1. Theme with two static page layouts, one with default = 1, where the other is listed first on disk.
  2. Create a new page without opening Settings and save.
  3. The page file has no layout; the other layout is used.

@daftspunk
daftspunk merged commit 61fb5d2 into rainlab:master Nov 14, 2026
3 checks passed
@daftspunk

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants