-
Notifications
You must be signed in to change notification settings - Fork 824
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 Handle getting HasOneRelationFieldInterface passed as an array #11213
FIX Handle getting HasOneRelationFieldInterface passed as an array #11213
Conversation
cb11847
to
76bae34
Compare
I think the validator is working correctly - the developer should use the correct field name when setting their validator, i.e. it should be RequiredFields::create(['MySiteTreeID']) and not RequiredFields::create(['MySiteTree']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll treat this PR as an enhancement instead of a bugfix, since I think the current behaviour isn't buggy, even though it's potentially confusing since some fields use the ID
suffix and some don't.
To that end, please update the commit prefix to ENH
.
3dbea62
to
9ade813
Compare
9ade813
to
b8f0b8c
Compare
Does the bug you're fixing affect CMS 5.2? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to reproduce the bug mentioned in the description both from the 5
and 5.2
branch - I can't reproduce it from either. Validation works fine without this PR in both scenarios.
Please try spinning up a fresh installation and testing your own reproduction steps.
Yeah looks like we don't need this one, I think there may have been some initial confusion with the "ID" suffix making me think things were broken when they were not |
Turns out we do need this one, it's required for doing a page save of an inline-block where the has_one SiteTree::class in in RequiredFields. It's NOT required for saving non-inline block's. It showed up as a behat failure in page-save-validation.feature on https://github.com/silverstripe/silverstripe-elemental/actions/runs/8961905824/job/24613378755?pr=1178#step:12:1052 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out there's a difference with some fields between "I have not selected anything" and "I have specifically clicked on the dropdown and selected the empty option".
Since form submission already correctly handles both cases, and it's been like that for donkey's years, I think it makes sense to handle this here as you've done.
Issue silverstripe/silverstripe-elemental#1155
This fixes bugs with autoscaffolded SearchableDropdownField for has_one SiteTree relations
Replication steps
You can leave the field blank and submit and the required fields validation won't trigger