diff --git a/README.md b/README.md index 3f539cd..a831c6d 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ This module provides a number of useful grid field components: features. * `GridFieldTitleHeader` - a simple header which displays column titles. * `GridFieldConfigurablePaginator` - a paginator for GridField that allows customisable page sizes. +* `GridFieldNestedForm` - allows nesting of GridFields for managing relation records directly within + a parent GridField. ## Installation diff --git a/docs/en/index.md b/docs/en/index.md index e5eb80c..6d2dbd0 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -166,3 +166,32 @@ $grid->getConfig()->addComponent(GridFieldNestedForm::create()); // Usage with custom relation $grid->getConfig()->addComponent(GridFieldNestedForm::create()->setRelationName('MyRelation')); ``` + +You can define your own custom GridField config for the nested GridField configuration by implementing a `getNestedConfig` +on your nested model (should return a `GridField_Config` object). +```php +class NestedObject extends DataObject +{ + private static $has_one = [ + 'Parent' => ParentObject::class + ]; + + public function getNestedConfig(): GridFieldConfig + { + $config = new GridFieldConfig_RecordViewer(); + return $config; + } +} +``` + +You can also modify the default config (a `GridFieldConfig_RecordEditor`) via an extension to the nested model class, by implementing +`updateNestedConfig`, which will get the config object as the first parameter. +```php +class NestedObjectExtension extends DataExtension +{ + public function updateNestedConfig(GridFieldConfig &$config) + { + $config->removeComponentsByType(GridFieldPaginator::class); + } +} +```