Skip to content

[6.x] Default values can be computed#14279

Merged
jasonvarga merged 8 commits intostatamic:6.xfrom
edalzell:feature/computed-defaults
Apr 2, 2026
Merged

[6.x] Default values can be computed#14279
jasonvarga merged 8 commits intostatamic:6.xfrom
edalzell:feature/computed-defaults

Conversation

@edalzell
Copy link
Copy Markdown
Contributor

@edalzell edalzell commented Mar 17, 2026

@edalzell edalzell changed the title Default values can be computed [6.x] Default values can be computed Mar 17, 2026
@edalzell edalzell requested a review from jasonvarga March 17, 2026 20:42
jasonvarga and others added 5 commits April 2, 2026 13:20
Avoids using PHP reserved word as method name and better matches
the existing Collection::computed() naming convention.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously would throw an unhelpful "Undefined array key" error
when a field referenced a computed default that was never registered.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move computed default callback storage from a static property on
Fields to instance state on FieldRepository (registered as a
singleton). This follows the established pattern used by
CollectionRepository for computed field callbacks, where the
container lifecycle handles cleanup between tests.

Also introduces a Statamic\Facades\Field facade for the repository.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jasonvarga jasonvarga merged commit 61aa099 into statamic:6.x Apr 2, 2026
17 checks passed
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.

Allow field defaults to be computed

2 participants