Skip to content

Conversation

@giuscris
Copy link
Member

This pull request introduces improvements to how nested data structures are handled in page content and configuration files by ensuring that "dotted" keys are properly expanded into nested arrays. The changes primarily focus on using the Arr::undot() utility to convert flattened arrays into nested ones, which helps maintain correct data structure throughout the application. Additionally, the logic for merging data arrays has been updated to use array_replace_recursive for more robust handling of nested values.

Improvements to nested data handling:

Enhancements to array merging logic:

  • formwork/src/Pages/Page.php: Uses array_replace_recursive instead of array spread for merging defaults and content file frontmatter into the page data, which improves handling of nested arrays and prevents overwriting nested values. [1] [2]
@giuscris giuscris added this to the 2.2.0 milestone Nov 16, 2025
@giuscris giuscris self-assigned this Nov 16, 2025
@giuscris giuscris added bug Something isn't working enhancement New feature or request labels Nov 16, 2025
@giuscris giuscris requested a review from Copilot November 16, 2025 09:41
@giuscris giuscris marked this pull request as ready for review November 16, 2025 09:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves how nested data structures are handled in page content and configuration by expanding dotted keys into proper nested arrays and switching to recursive array merging for more robust handling of nested values.

Key Changes

  • Applies Arr::undot() to frontmatter and defaults to convert dotted keys (e.g., metadata.title) into nested arrays (e.g., ['metadata' => ['title' => ...]])
  • Replaces array spread operator with array_replace_recursive() for merging data, which preserves nested values that aren't explicitly overridden

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
formwork/src/Pages/ContentFile.php Adds Arr::undot() to convert dotted keys in YAML frontmatter to nested arrays
formwork/src/Pages/Page.php Updates data merging to use array_replace_recursive() and applies Arr::undot() to defaults for consistent nested structure handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@giuscris giuscris merged commit af2530d into 2.x Nov 16, 2025
7 checks passed
@giuscris giuscris deleted the fix/unmerged-page-nested-arrays-data branch November 16, 2025 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

2 participants