Skip to content

[9.x] Fix nested JSON fields in title_field and title_format - #844

Merged
duncanmcclean merged 6 commits into
9.xfrom
703
Sep 4, 2026
Merged

duncanmcclean merged 6 commits into
9.xfrom
703

Conversation

@duncanmcclean

@duncanmcclean duncanmcclean commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

This pull request fixes an issue where the title_field resource option and the title_format fieldtype option couldn't reference fields nested inside JSON columns.

This was happening because every consumer of title_field read the value with $model->getAttribute($titleField) or magic property access, both of which return null for a nested handle like address_street_name. The one place it did work was the relationship fieldtype's selected items, which resolve the title through augmentation instead.

The issue also asked which syntax is correct, so for the record: it's the nested handle (address_street_name), same as anywhere else in a blueprint. The arrow form (address->street_name) is the database column Runway generates internally, and was never a valid blueprint handle — which is why the listing title rendered but didn't link.

This PR fixes it by adding getFieldValue() to the HasRunwayResource trait as the read-side counterpart to getFieldColumn(), then routing titles through it: listings, the edit form, publish form values, revisions, search results and relationship columns. Query-side paths now convert the handle to a column, so sorting in the stack selector, the relationship filter, runwaySearch and duplication work with a nested title field too.

This PR also fixes:

  • Nested fields whose prefix contains an underscore (eg. external_links) always augmenting to null, since AugmentedModel derived the prefix with Str::before($handle, '_'). This affects title_format, which reads values through augmentation.
  • Nested fields being excluded from runwaySearch entirely, since the "does this map to a real column?" check tested the field handle instead of the column it maps to.
  • Nested fields listed in a search index's fields being indexed as null, since Searchable also read them with magic property access.

While here, getColumnForField() has been renamed to getFieldColumn() to match. The old name still works, but is deprecated.

The docs for both options have been updated to mention nested fields.

Fixes #703

every `title_field` consumer read the value with `getAttribute()` or magic
property access, both of which return null for a nested handle like
`metadata_sku`. adds `getValueForField()` as the read-side counterpart to
`getColumnForField()` and routes titles through it.

query-side paths (sorting in the stack selector, the relationship filter,
`runwaySearch`, `DuplicateModel`) now convert the handle to a column.

also fixes `AugmentedModel::wrapNestedField()` deriving the prefix with
`Str::before($handle, '_')`, which returned null for any prefix containing
an underscore.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@duncanmcclean
duncanmcclean marked this pull request as draft August 3, 2026 10:38
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014CMma1jbzQJrxE5vmRhVpH
@duncanmcclean
duncanmcclean marked this pull request as ready for review September 4, 2026 09:08
duncanmcclean and others added 4 commits September 4, 2026 10:09
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014CMma1jbzQJrxE5vmRhVpH
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014CMma1jbzQJrxE5vmRhVpH
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014CMma1jbzQJrxE5vmRhVpH
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014CMma1jbzQJrxE5vmRhVpH
@duncanmcclean
duncanmcclean merged commit 4579631 into 9.x Sep 4, 2026
15 checks passed
@duncanmcclean
duncanmcclean deleted the 703 branch September 4, 2026 09:48
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Released as part of v9.7.0.

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.

Can't use title_format/title_field options with nested fields

1 participant