Repository navigation
fix: incorrect value inside beforeValidate field hooks - #11433
Conversation
|
🚀 This is included in version v3.26.0 |
|
@JarrodMFlesch This appears to break required fields with access false, doesn't it? At least, in my app, example:
Now, the fallback happens before access control and the fallback value is thus deleted. I don't think this PR should be rolled back, the new situation makes more sense to me, but maybe this was an unintended consequence. Edit: worked around be removing field access control, and overwriting user value in |
|
@JarrodMFlesch Actually, this is fundamentally broken now, for any field that the user is not allowed to update. Example: {
name: 'group',
type: 'relationship',
relationTo: 'groups',
required: true,
access: {
update: () => false,
}
}If I previously updated another field, it would delete the I'll open the issue |
### What? Regression caused by #11433 If a beforeChange hook was checking for a missing or undefined `value` in order to change the value before inserting into the database, data could be lost. ### Why? In #11433 the logic for setting the fallback field value was moved above the logic that cleared the value when access control returned false. ### How? This change ensures that the fallback value is passed into the beforeValidate function _and_ still available with the fallback value on siblingData if access control returns false. Fixes #11543
What?
valuewithin the beforeValidate field hook was not correctly falling back to the document value when no value was passed inside the request for the field.Why?
The fallback logic was running after the beforeValidate field hooks are called.
How?
Run the fallback logic before running the beforeValidate field hooks.
Fixes #10923