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 bug: DropdownField::create(...)->setHasEmptyDefault(true) was not effective #2516
Conversation
… effective, but now is.
There's already a test for this, but maybe it's not done properly? I'm not familiar enough to know one way or the other. |
Last two commits properly cleans up the code and adds more in-depth tests. |
This fails tests related to DropdownField https://travis-ci.org/silverstripe/silverstripe-framework/builds/12347466 |
As the comment for getSource() says "Gets the source array including any empty default values." you're changing that behaviour so we'll need to put this into 3.2 rather to 3.1 as a start as it's not crazy for another developer to use getSource() on another drop down. It looks like the tests assume the behaviour that getSource() will return the default values. For me, it makes better sense for getSource() to not return the blank value so I agree with the PR, you'll just need to submit against 3.2 and play around with DropdownFieldTest. Any questions on testing I'm happy to help. |
I'm not sure if you noticed, but I updated the test. I'm not sure if the unit test validated using the new one (d1808c3) or using the old one (1d7a05c or before). Before my changes to the test:
It now checks:
|
@wilr Could you peer review please? :) |
Ok so the tests still needed a bit of work, most of the test cases you added were already present and needed to be updated for said API change to getSource(). Tidied and pushed to master in fee54c7 thanks |
Found this bug when upgrading to 3.1.
Our original code in
Page.php
(which should work on any standard CMS setup):Was updated to:
The only difference is using ArrayList instead of DataList (working around a bug in 3.0).
I tracked down the bug to
DropdownField.php
where it was checking$this->emptyString
instead of$this->getHasEmptyDefault()
.