fix fields validation to include field presets #10882
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #10854
Bug
Field presets are not taken into account during validation. Even though the field is already filled by preset, the form returns
value is required
:Investigation
During the validation process,
fields.value
are checked with conditions and if default value isNil:directus/app/src/composables/use-item/use-item.ts
Lines 326 to 337 in 8cdb6ed
However
fields.value
came from useCollection:directus/app/src/composables/use-item/use-item.ts
Line 39 in 8cdb6ed
Which does not have field presets merged as default values. Fields with presets are returned from usePermission instead:
directus/app/src/composables/use-permissions.ts
Lines 73 to 87 in 8cdb6ed
Solution
This PR requires #10782 to be fixed first, due to the presets wrongly parsed as filter syntax. That causes it to be interpreted as creating a new relational item instead: