Merge pull request #9452 from botzkobg/GridFieldDocsUpdate

Fix issue with the GridField documenation
This commit is contained in:
Loz Calver 2020-04-06 09:38:44 +01:00 committed by GitHub
commit bcab982aa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -329,6 +329,7 @@ The namespace notation is `ManyMany[<extradata-field-name>]`, so for example `Ma
use SilverStripe\Forms\TextField; use SilverStripe\Forms\TextField;
use SilverStripe\Forms\GridField\GridField; use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor;
use SilverStripe\Forms\GridField\GridFieldDetailForm;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
class Team extends DataObject class Team extends DataObject
@ -338,7 +339,7 @@ class Team extends DataObject
'Name' => 'Text' 'Name' => 'Text'
]; ];
public static $many_many = [ public static $belongs_many_many = [
'Players' => 'Player' 'Players' => 'Player'
]; ];
} }
@ -372,7 +373,7 @@ class Player extends DataObject
); );
$config = GridFieldConfig_RelationEditor::create(); $config = GridFieldConfig_RelationEditor::create();
$config->getComponentByType('GridFieldDetailForm')->setFields($teamFields); $config->getComponentByType(GridFieldDetailForm::class)->setFields($teamFields);
$gridField = new GridField('Teams', 'Teams', $this->Teams(), $config); $gridField = new GridField('Teams', 'Teams', $this->Teams(), $config);
$fields->findOrMakeTab('Root.Teams')->replaceField('Teams', $gridField); $fields->findOrMakeTab('Root.Teams')->replaceField('Teams', $gridField);