Closed GuySartorelli closed 1 week ago
... Because of that, I also can't sensibly stop performReadonlyTransformation() from calling it, so readonly versions of the field will still suck when you have large datasets. If that specific scenario becomes a problem for someone we can look at dealing with it ...
@GuySartorelli Unfortunately this scenario is indeed a problem. The reason we noticed the lazy loading problem in the first place was the scaffolding for DataObjects in Model admin. With this fix it is now possible to open Detailforms for existing DataObjects. But you can't create nested DataObjects anymore.
If you have ModelA that has_many ModelB and you open the Detailform for ModelA, than a GridField for ModelB will be added to the form. If you click on "Add new ModelB" the NewItemForm will try to make the Field for the has_one ModelA readonly ...
The workaround for now is to remove the field in the NewItemForm.
@johannesx75 I've opened https://github.com/silverstripe/silverstripe-framework/issues/11293 as a follow-up issue to handle specifically readonly fields. If you'd like to try tackling it with a new pull request that will greatly improve the chances that this is resolved.
I didn't fully understand what you were saying in your comment but given you quoted the bit about readonly fields, I assume that's what the problem is.
We replaced the auto-scaffolding of has_one form fields with this new thing, and we said it would be better because you don't need the
NumericField
fallback anymore - but the workaround in the linked issue is to manually replace the field withNumericField
so we've obviously messed up there.Ultimately
getSource()
should just return theDataList
directly, but we can't do that in a minor much less a patch because the return type is strongly typed for that method.In the meantime, the new logic avoids calling
getSource()
altogether as much as we can avoid it, since calling that method is usually not required.I couldn't remove it being called from
castedCopy()
without copying a bunch of boilerplate fromFormField
- and it is a pretty messy method. Because of that, I also can't sensibly stopperformReadonlyTransformation()
from calling it, so readonly versions of the field will still suck when you have large datasets. If that specific scenario becomes a problem for someone we can look at dealing with it, but until someone complains about it I'm inclined to leave it alone for CMS 5.Issue