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

FIX Treat value not in SingleSelectField options as blank #1872

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Dec 11, 2024

This makes the react dropdown fields behave more like the entwine ones when the DB value is not in the set of dropdown options.

Note that the reproduction steps in the issue rely on the DB field being Int (or perhaps other numeric fields as well - but specifically not a string type). This is because its default value is 0, while the default for Varchar for example is null which wouldn't exhibit the bug.

Issue

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

This feels like a pretty messy way to handle this. I think we're better off handling this on the PHP side if possible. SingleSelectField::getDefaultValue() seems like the place where we should be checking if the value is in the source values and if not, then set the value to null. The results of that will be passed to the form schema.

@GuySartorelli
Copy link
Member Author

Good point. Closing in favour of silverstripe/silverstripe-framework#11510

@GuySartorelli GuySartorelli deleted the pulls/2.3/singleselect-no-value branch December 12, 2024 20:48
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.

2 participants