Skip to content

[9.x] Support nested fields in title_field and title_format#808

Draft
duncanmcclean wants to merge 1 commit into
9.xfrom
nested-title-fields
Draft

[9.x] Support nested fields in title_field and title_format#808
duncanmcclean wants to merge 1 commit into
9.xfrom
nested-title-fields

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where setting title_field to a nested field (e.g., values_alt_title) didn't work correctly. Listings would either show blank titles or relationship fields would fail to display titles, depending on whether the arrow (meta->name) or underscore (meta_name) syntax was used.

This was happening because all call sites that read the title value used direct attribute access ($model->getAttribute(...) or $model->{$titleField}), which can't resolve values from nested JSON columns. Nested fields need to be read using data_get($model, "prefix.key").

This PR fixes it by adding three helper methods to Resource:

  • titleValue(Model $model) — reads the title value from a model, using data_get() for nested fields
  • titleDbColumn() — returns the database column path (e.g., values->alt_title) for use in query ordering
  • setTitleValue(Model $model, $value) — writes a title value back to the model, handling nested JSON columns

All call sites that previously accessed the title value directly now use these methods instead.

Fixes #703

@duncanmcclean duncanmcclean marked this pull request as draft April 17, 2026 11:50
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