Permalink
Browse files

BUGFIX: Allow modification of a config's components after the grid fi…

…eld is instantiated.
  • Loading branch information...
1 parent 7201f06 commit c8e994d5732a7eaf7883550ce2d039ccad875f6a @sminnee sminnee committed May 18, 2012
Showing with 10 additions and 18 deletions.
  1. +10 −18 forms/gridfield/GridField.php
@@ -79,7 +79,6 @@ public function __construct($name, $title = null, SS_List $dataList = null, Grid
}
$this->config->addComponent(new GridState_Component());
- $this->setComponents($this->config);
$this->state = new GridState($this);
@@ -118,17 +117,6 @@ public function getModelClass() {
throw new LogicException('GridField doesn\'t have a modelClassName, so it doesn\'t know the columns of this grid.');
}
-
- /**
- * Set which GridFieldComponent's that this GridFields contain by using a GridFieldConfig
- *
- * @param GridFieldConfig $config
- * @see GridFieldComponent
- */
- protected function setComponents(GridFieldConfig $config) {
- $this->components = $config->getComponents();
- return $this;
- }
/**
* Get the GridFieldConfig
@@ -139,6 +127,10 @@ public function getConfig() {
return $this->config;
}
+ public function getComponents() {
+ return $this->config->getComponents();
+ }
+
/**
* Cast a arbitrary value with the help of a castingDefintion
*
@@ -224,7 +216,7 @@ public function FieldHolder($properties = array()) {
// Get data
$list = $this->getList();
- foreach($this->components as $item) {
+ foreach($this->getComponents() as $item) {
if($item instanceof GridField_DataManipulator) {
$list = $item->getManipulatedData($this, $list);
}
@@ -238,7 +230,7 @@ public function FieldHolder($properties = array()) {
"footer" => "",
);
- foreach($this->components as $item) {
+ foreach($this->getComponents() as $item) {
if($item instanceof GridField_HTMLProvider) {
$fragments = $item->getHTMLFragments($this);
if($fragments) foreach($fragments as $k => $v) {
@@ -382,7 +374,7 @@ public function getAttributes() {
public function getColumns() {
// Get column list
$columns = array();
- foreach($this->components as $item) {
+ foreach($this->getComponents() as $item) {
if($item instanceof GridField_ColumnProvider) {
$item->augmentColumns($this, $columns);
}
@@ -499,7 +491,7 @@ public function getColumnCount() {
*/
protected function buildColumnDispatch() {
$this->columnDispatch = array();
- foreach($this->components as $item) {
+ foreach($this->getComponents() as $item) {
if($item instanceof GridField_ColumnProvider) {
$columns = $item->getColumnsHandled($this);
foreach($columns as $column) {
@@ -563,7 +555,7 @@ public function gridFieldAlterAction($data, $form, SS_HTTPRequest $request) {
*/
public function handleAction($actionName, $args, $data) {
$actionName = strtolower($actionName);
- foreach($this->components as $component) {
+ foreach($this->getComponents() as $component) {
if(!($component instanceof GridField_ActionProvider)) {
continue;
}
@@ -591,7 +583,7 @@ function handleRequest(SS_HTTPRequest $request, DataModel $model) {
$fieldData = $this->request->requestVar($this->getName());
if($fieldData && $fieldData['GridState']) $this->getState(false)->setValue($fieldData['GridState']);
- foreach($this->components as $component) {
+ foreach($this->getComponents() as $component) {
if(!($component instanceof GridField_URLHandler)) {
continue;
}

0 comments on commit c8e994d

Please sign in to comment.