silverstripe / silverstripe-framework

Silverstripe Framework, the MVC framework that powers Silverstripe CMS
https://www.silverstripe.org
BSD 3-Clause "New" or "Revised" License
720 stars 820 forks source link

`performReadonlyTransformation()` for `SearchableDropdownField` and `SearchableMultiDropdownField` doesn't respect lazy loading #11293

Open GuySartorelli opened 3 days ago

GuySartorelli commented 3 days ago

A follow-up to https://github.com/silverstripe/silverstripe-framework/issues/11272

If you call performReadonlyTransformation() on a SearchableDropdownField or SearchableMultiDropdownField, it will convert the source DataList into an array, which requires pulling data for all records in the list from the database.

All that's really needed is data for the record(s) which are currently selected for the field, since it's read-only it doesn't matter what other options could have been selected, because they weren't selected.

We may need to create a new readonly formfield for these - at the very least we'll need to implement some specific logic in the performReadonlyTransformation() method to instantiate the readonly field correctly without pulling unnecessary data.

Acceptance criteria

johannesx75 commented 2 days ago

I'm working on it. Feel free to assign the issue to me.

Me first Idea was to overwrite performReadonlyTransformation and just change source to the selected items if the control is readonly.

Unfortunately that wont work. The value can still be set on a readonly Formfield. For example in form scaffolding the field is created and performReadonlyTransformation is run before the value is set.

So the acceptance criteria is probably missing changes to the value after performReadonlyTransformation.