-
Notifications
You must be signed in to change notification settings - Fork 823
Fix perform readonly transformation for lazyloaded searchabledropdown #11297
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 perform readonly transformation for lazyloaded searchabledropdown #11297
Conversation
2fbc516
to
f23bea6
Compare
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.
Have tested locally, works well, just a few small changes to make
Not that I've changed the base from 5.2 to 5 (so will be released in CMS 5.3), because this is adding new API so to follow semver it needs to be released in a new minor
You'll need to rebase on top of 5
as there's now a merge-conflict
f23bea6
to
e1f4516
Compare
e1f4516
to
6988222
Compare
@emteknetnz, sorry for the late response. I was out sick. Think I've made all the requested changes. One of the checks fails: 'CI / CI / 8.1 mysql57 phplinting (pull_request)'. From what I can tell thats unrelated to my changes. |
Description
performReadonlyTransformation() on a SearchableDropdownField or SearchableMultiDropdownField, will convert the source DataList into an array, which requires pulling data for all records in the list from the database.
This is caused by the performReadonlyTransformation of the underlying SingleSelectField and MultiSelectField calling getSource. To circumvent this a new LazyLoadedLookupField is used. It has the same logic as SearchableDropdownTrait to use a Datalist internally for the Source.
This also contains the fix for #11294, since the wrong initial value of "Title" was messing up the control.
Please note: This solution feels like quite a hack. I really don't like the fact, that getSource is not really returning the source. But I figured as long as SearchableDropdownTrait works this way the performReadonlyTransformation should be similar to it.
Manual testing steps
Given ModelA has_one ModelB and ModelB has_many ModelA:
Issues
performReadonlyTransformation()
forSearchableDropdownField
andSearchableMultiDropdownField
doesn't respect lazy loading #11293Pull request checklist