NEW Add set config method to GridField.

This commit is contained in:
Andrew Short 2012-07-04 13:03:13 +10:00
parent 9c57294aa9
commit eb733dee60

15
forms/gridfield/GridField.php Executable file → Normal file
View File

@ -80,11 +80,7 @@ class GridField extends FormField {
$this->setList($dataList); $this->setList($dataList);
} }
if(!$config) { $this->setConfig($config ?: GridFieldConfig_Base::create());
$this->config = GridFieldConfig_Base::create();
} else {
$this->config = $config;
}
$this->config->addComponent(new GridState_Component()); $this->config->addComponent(new GridState_Component());
$this->state = new GridState($this); $this->state = new GridState($this);
@ -134,6 +130,15 @@ class GridField extends FormField {
return $this->config; return $this->config;
} }
/**
* @param GridFieldConfig $config
* @return GridField
*/
public function setConfig(GridFieldConfig $config) {
$this->config = $config;
return $this;
}
public function getComponents() { public function getComponents() {
return $this->config->getComponents(); return $this->config->getComponents();
} }