Closed GuySartorelli closed 9 months ago
My proposed rules of thumb for what "where practical" means:
ViewableData
means just hiding the component or making the component do nothing, then that is not practical. Hiding a component or disabling a component is not making the component work and those should throw clear exceptions instead. e.g. GridFieldDetailForm_ItemRequest
ViewableData
by providing setters for information that would otherwise be fetched from DataObjects
- e.g. GridFieldDetailForm
allows setting a validator, fields, and even a custom item request class in lieu of GridFieldDetailForm_ItemRequest
.
"Implement $missingMethod on your data class or call $setterMethod on this component"
.DataObject
that it's not practical to find workarounds for it all. One example is GridFieldDetailForm_ItemRequest
. In these cases, the PHPDoc for the class should clearly note that it is intended for use with DataObject
.
DataObject
, but we can check up-front for the methods or fields we're expecting and throw an exception if any are missing. That may seem cumbersome but it's probably easier than adding a method_exists()
or ->hasMethod()
or ClassInfo::hasMethod()
check for every method we want to call on the record and provides a much clearer DX as to why this component isn't working for them.The following modules have GridField components:
Maybe updating those is beyond the scope of this card.
@maxime-rainville I already made a card for symbiote/silverstripe-gridfieldextensions
since that has generic components (see link in issue description)
Advanced workflow is explicitly out of scope - as are a few others there which are only intended to be used in the way the module uses it, rather than in developer-defined gridfields. ckan-registry isn't even supported anymore....
Maybe open a card to cover any there which:
It is done.
Currently most
GridFieldComponent
classes implicitly require some methods which are implemented onDataObject
but not onViewableData
.It is not uncommon to want to use a
GridField
with other viewable data, such asArrayData
(e.g. pulled from some API).It should be easy to use most
GridField
components with arbitraryViewableData
. Any components for which this is not practical should be clearly documented as requiring specific methods (and in CMS 6 probably will be typehinted toDataObject
).Acceptance Criteria
GridFieldComponent
classes work with arbitraryViewableData
ViewableData
(if any), this is clearly documented in a way that developers can identify from within their IDE.Notes
PRs