I am attempting to update the secure files silverstripe module to SS3.
In it, the author uses the following ComplexTableField:
class SecureFileTokenPermissionDecorator extends DataExtension {
static $has_many = array(
'AccessTokens' => 'SecureFileAccessToken'
);
....
$tokenList = new ComplexTableField(
$this->owner,
'ContainedFileTokens',
'SecureFileAccessToken',
null,
null,
"File.ParentID = '{$this->owner->ID}'",
$sourceSort = null,
"JOIN File ON FileID = File.ID"
));
$tokenList->setParentIdName('FolderID');
$tokenList->setRelationAutoSetting(false);
....
}
I was wondering how I would go about representing the same data/relation with gridfField.
Thanks!
Looking at the secure files module source code, I would suggest the following setup:
This works directly on the relation getter, which is a lazy loaded list (not queried until necessary), and automatically paginated. I’m not quite sure how the
setParentIdName("FolderID")fits in here, probably unnecessary. Caution: Haven’t tried this on the actual codebase.If you need some help understanding the API on a higher level, have a look in the GridField docs and the “datamodel” topic.
Thanks for helping to make modules ready for SS3! 🙂