Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Drop default values from fieldtypes #10272

Merged
merged 4 commits into from
Jun 5, 2024

Conversation

duncanmcclean
Copy link
Member

In Statamic 5, we introduced some changes to how field configs work. Instead of saving all of a field's config options in a blueprint or fieldset's YAML file, we only saved the config options that differ from the option's default. This change is intended to help tidy up blueprints & fieldsets.

As a side affect of this change, it meant that when fieldtypes went to get their config values, they'd only be able to access those config options which are explicitly set in the field config (eg. the config values which differ from their defaults).

We fixed this in #10139, where the Fieldtype::config() method now merges in the default values from the fieldtype's config options.

However, as a result of this fix, it means that the $defaultValue property set on some of our fieldtypes would be the value it'd fallback to.

For some of our fieldtypes (including the Relationship one), the default value was set to an empty array. However, our fieldtypes were expecting to get null when no value was provided.

This PR fixes that by removing the $defaultValue = [] property from some of our fieldtypes, to ensure the default value for them is null.

Fixes #10268.
Replaces #10270.

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.

link field causes 500 error if an asset container is not specified
2 participants