Permalink
Browse files

BUGFIX: Fixed notice-level errors in GridField, exposed by test failu…

…res.
  • Loading branch information...
sminnee committed Jan 10, 2012
1 parent 06605ff commit 489191b44f645d77488e698b0bdeef9f2198afdf
Showing with 10 additions and 11 deletions.
  1. +9 −10 forms/gridfield/GridField.php
  2. +1 −1 tests/forms/GridFieldTest.php
@@ -399,8 +399,8 @@ public function getColumnContent($record, $column) {
$this->buildColumnDispatch();
}
- $handler = $this->columnDispatch[$column];
- if($handler) {
+ if(!empty($this->columnDispatch[$column])) {
+ $handler = $this->columnDispatch[$column];
return $handler->getColumnContent($this, $record, $column);
} else {
throw new InvalidArgumentException("Bad column '$column'");
@@ -422,8 +422,8 @@ public function getColumnAttributes($record, $column) {
$this->buildColumnDispatch();
}
- $handler = $this->columnDispatch[$column];
- if($handler) {
+ if(!empty($this->columnDispatch[$column])) {
+ $handler = $this->columnDispatch[$column];
$attrs = $handler->getColumnAttributes($this, $record, $column);
if(is_array($attrs)) {
return $attrs;
@@ -451,8 +451,8 @@ public function getColumnMetadata($column) {
$this->buildColumnDispatch();
}
- $handler = $this->columnDispatch[$column];
- if($handler) {
+ if(!empty($this->columnDispatch[$column])) {
+ $handler = $this->columnDispatch[$column];
$metadata = $handler->getColumnMetadata($this, $column);
if(is_array($metadata)) {
return $metadata;
@@ -502,13 +502,12 @@ public function gridFieldAlterAction($data, $form, SS_HTTPRequest $request) {
$stateChange = Session::get($id);
$gridName = $stateChange['grid'];
$grid = $form->Fields()->dataFieldByName($gridName);
-
+
$state = $grid->getState(false);
- $state->setValue($data['GridState']);
+ if(isset($data['GridState'])) $state->setValue($data['GridState']);
$actionName = $stateChange['actionName'];
-
- $args = $stateChange['args'];
+ $args = isset($stateChange['args']) ? $stateChange['args'] : array();
$grid->handleAction($actionName, $args, $data);
switch($request->getHeader('X-Get-Fragment')) {
@@ -315,7 +315,7 @@ public function testGridFieldAlterAction() {
$obj = new GridField('testfield', 'testfield', ArrayList::create(), $config);
$id = 'testGridStateActionField';
Session::set($id, array('grid'=>'', 'actionName'=>'jump'));
- $form = new Form($this, 'mockform', new FieldList(array($obj)), new FieldList());
+ $form = new Form(new Controller(), 'mockform', new FieldList(array($obj)), new FieldList());
$request = new SS_HTTPRequest('POST', 'url');
$obj->gridFieldAlterAction(array('StateID'=>$id), $form, $request);
}

0 comments on commit 489191b

Please sign in to comment.