Normalize data structure by removing dots when merging defaults and frontmatter #786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 usearray_replace_recursivefor more robust handling of nested values.Improvements to nested data handling:
formwork/src/Pages/ContentFile.php: Now usesArr::undot()to convert dotted keys in frontmatter to nested arrays when loading content files, ensuring correct data structure. [1] [2]formwork/src/Pages/Page.php: Returns undotted (nested) defaults in thedefaults()method by applyingArr::undot().Enhancements to array merging logic:
formwork/src/Pages/Page.php: Usesarray_replace_recursiveinstead 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]