From eb733dee60a7267dd9ed918d290b30581b41df78 Mon Sep 17 00:00:00 2001 From: Andrew Short Date: Wed, 4 Jul 2012 13:03:13 +1000 Subject: [PATCH] NEW Add set config method to GridField. --- forms/gridfield/GridField.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) mode change 100755 => 100644 forms/gridfield/GridField.php diff --git a/forms/gridfield/GridField.php b/forms/gridfield/GridField.php old mode 100755 new mode 100644 index 7ea9ce4c8b4..59f16c80398 --- a/forms/gridfield/GridField.php +++ b/forms/gridfield/GridField.php @@ -79,13 +79,9 @@ public function __construct($name, $title = null, SS_List $dataList = null, Grid if($dataList) { $this->setList($dataList); } - - if(!$config) { - $this->config = GridFieldConfig_Base::create(); - } else { - $this->config = $config; - } - + + $this->setConfig($config ?: GridFieldConfig_Base::create()); + $this->config->addComponent(new GridState_Component()); $this->state = new GridState($this); @@ -133,7 +129,16 @@ public function getModelClass() { public function getConfig() { return $this->config; } - + + /** + * @param GridFieldConfig $config + * @return GridField + */ + public function setConfig(GridFieldConfig $config) { + $this->config = $config; + return $this; + } + public function getComponents() { return $this->config->getComponents(); }