From b67f99adbe0d3b90f50d93f4e3b3372711fb5161 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 9 Mar 2012 18:24:18 +1300 Subject: [PATCH] BUGFIX: Make frameworktest rely on built-in gridfield configs --- code/Company.php | 9 +-------- code/GridFieldTestPage.php | 36 ++++-------------------------------- 2 files changed, 5 insertions(+), 40 deletions(-) diff --git a/code/Company.php b/code/Company.php index b217e92..886d7d5 100644 --- a/code/Company.php +++ b/code/Company.php @@ -37,14 +37,7 @@ class Company extends DataObject { $fields->add(new TextField('Revenue', 'Revenue', $this->Revenue)); $fields->add(new TextField('CEO', 'CEO', $this->CEO)); - $config = new GridFieldConfig(); - $config->addComponent(new GridFieldRelationAdd('Name')); - $config->addComponent(new GridFieldDefaultColumns()); - $config->addComponent(new GridFieldSortableHeader()); - $config->addComponent(new GridFieldPaginator()); - $config->addComponent(new GridFieldDeleteAction()); - $config->addComponent(new GridFieldRelationDelete()); - $config->addComponent(new GridFieldPopupForms()); + $config = new GridFieldConfig_RelationEditor(); $gridField = new GridField('Employees', 'Employees', $this->Employees(), $config); $fields->add($gridField); diff --git a/code/GridFieldTestPage.php b/code/GridFieldTestPage.php index f583deb..5661106 100644 --- a/code/GridFieldTestPage.php +++ b/code/GridFieldTestPage.php @@ -31,36 +31,15 @@ class GridFieldTestPage extends Page { public function getCMSFields() { $fields = parent::getCMSFields(); - $config = new GridFieldConfig(); - $config->addComponent(new GridFieldDefaultColumns()); - $config->addComponent(new GridFieldSortableHeader()); - $config->addComponent(new GridFieldPaginator); - $config->addComponent(new GridFieldFilter()); - $config->addComponent(new GridFieldDeleteAction()); - $config->addComponent(new GridFieldEditAction()); - $config->addComponent($forms = new GridFieldPopupForms()); + $config = new GridFieldConfig_RecordEditor(); $grid = new GridField('Companies', 'Companies', new DataList('Company'),$config); $fields->addFieldToTab('Root.NoRelation', $grid); - $config = new GridFieldConfig(); - $config->addComponent(new GridFieldDefaultColumns()); - $config->addComponent(new GridFieldSortableHeader()); - $config->addComponent(new GridFieldPaginator); - $config->addComponent(new GridFieldFilter()); - $config->addComponent(new GridFieldDeleteAction()); - $config->addComponent(new GridFieldEditAction()); - $config->addComponent(new GridFieldRelationAdd('Name')); + $config = new GridFieldConfig_RelationEditor(); $grid = new GridField('HasManyCompanies', 'HasManyCompanies', new DataList('Company'),$config); $fields->addFieldToTab('Root.HasMany', $grid); - $config = new GridFieldConfig(); - $config->addComponent(new GridFieldDefaultColumns()); - $config->addComponent(new GridFieldSortableHeader()); - $config->addComponent(new GridFieldPaginator); - $config->addComponent(new GridFieldFilter()); - $config->addComponent(new GridFieldDeleteAction()); - $config->addComponent(new GridFieldEditAction()); - $config->addComponent(new GridFieldRelationAdd('Name')); + $config = new GridFieldConfig_RelationEditor(); $grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', new DataList('Company'),$config); $fields->addFieldToTab('Root.ManyMany', $grid); @@ -86,14 +65,7 @@ class GridFieldTestPage_Controller extends Page_Controller { * @return Form */ public function Form(){ - $config = new GridFieldConfig(); - $config->addComponent(new GridFieldDefaultColumns()); - $config->addComponent(new GridFieldSortableHeader()); - $config->addComponent(new GridFieldPaginator); - $config->addComponent(new GridFieldFilter()); - $config->addComponent(new GridFieldDeleteAction()); - $config->addComponent(new GridFieldEditAction()); - $config->addComponent(new GridFieldPopupForms()); + $config = new GridFieldConfig_RecordEditor(); $grid = new GridField('Companies', 'Companies', new DataList('Company'),$config); return new Form($this,'Form',new FieldList($grid),new FieldList());