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

Check for component before saving, fallback to full form field name #10274

Merged

Conversation

tiller1010
Copy link
Contributor

Closes #10188

Summary

Prevents Call to a member function setCastedField() on null error when using dot syntax for has_many components. This does not save has_many components by itself.

Additional notes

We have custom code that handles the saving of has_many components with dot syntax. This change breaks that functionality. This simply checks for a valid component before calling setCastedField. If the component does not exist, this will fallback to the original setCastedField procedure.

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. This effectively reverts back to the old behaviour it no component could be found - which a) avoids the null pointer exception this is meant to resolve, and b) allows for custom logic to choose what to do with the data in this situation where a component hasn't yet been created.

@GuySartorelli GuySartorelli merged commit 35d5f16 into silverstripe:4 May 9, 2022
@tiller1010 tiller1010 deleted the check-for-dot-syntax-component branch May 11, 2022 12:56
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.

FormField saveInto dot syntax does not work for has_many components
2 participants