Skip to content

[6.x] Respect field defaults when querying - #15900

Open
edalzell wants to merge 3 commits into
statamic:6.xfrom
edalzell:fix/default-value-query
Open

edalzell wants to merge 3 commits into
statamic:6.xfrom
edalzell:fix/default-value-query

Conversation

@edalzell

Copy link
Copy Markdown
Contributor

Entries that have never saved a field with a blueprint default are indexed as null, so {{ collection:my_collection my_toggle:is="true" }} skips them until they are re-saved, even though templates show the default. The same applies to terms, assets, users, globals, forms and submissions.

This adds Field::toQueryableValue(), which falls back to the field's default when the value is null, and uses it wherever queryable values are resolved. Computed defaults and a date default of now are skipped, since they resolve at runtime and would otherwise be frozen into the Stache index.

Existing Stache indexes keep their old values until php please stache:refresh.

Closes #15735

@edalzell
edalzell force-pushed the fix/default-value-query branch from 5af830c to 328a76a Compare November 14, 2026 03:56
@edalzell
edalzell marked this pull request as ready for review November 14, 2026 04:02

This branch has not been deployed

No deployments
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.

Tag condition not respecting default value

1 participant