mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX: Fixed notice-level errors in GridField, exposed by test failures.
This commit is contained in:
parent
06605ffadc
commit
489191b44f
@ -399,8 +399,8 @@ class GridField extends FormField {
|
|||||||
$this->buildColumnDispatch();
|
$this->buildColumnDispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
$handler = $this->columnDispatch[$column];
|
if(!empty($this->columnDispatch[$column])) {
|
||||||
if($handler) {
|
$handler = $this->columnDispatch[$column];
|
||||||
return $handler->getColumnContent($this, $record, $column);
|
return $handler->getColumnContent($this, $record, $column);
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidArgumentException("Bad column '$column'");
|
throw new InvalidArgumentException("Bad column '$column'");
|
||||||
@ -422,8 +422,8 @@ class GridField extends FormField {
|
|||||||
$this->buildColumnDispatch();
|
$this->buildColumnDispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
$handler = $this->columnDispatch[$column];
|
if(!empty($this->columnDispatch[$column])) {
|
||||||
if($handler) {
|
$handler = $this->columnDispatch[$column];
|
||||||
$attrs = $handler->getColumnAttributes($this, $record, $column);
|
$attrs = $handler->getColumnAttributes($this, $record, $column);
|
||||||
if(is_array($attrs)) {
|
if(is_array($attrs)) {
|
||||||
return $attrs;
|
return $attrs;
|
||||||
@ -451,8 +451,8 @@ class GridField extends FormField {
|
|||||||
$this->buildColumnDispatch();
|
$this->buildColumnDispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
$handler = $this->columnDispatch[$column];
|
if(!empty($this->columnDispatch[$column])) {
|
||||||
if($handler) {
|
$handler = $this->columnDispatch[$column];
|
||||||
$metadata = $handler->getColumnMetadata($this, $column);
|
$metadata = $handler->getColumnMetadata($this, $column);
|
||||||
if(is_array($metadata)) {
|
if(is_array($metadata)) {
|
||||||
return $metadata;
|
return $metadata;
|
||||||
@ -502,13 +502,12 @@ class GridField extends FormField {
|
|||||||
$stateChange = Session::get($id);
|
$stateChange = Session::get($id);
|
||||||
$gridName = $stateChange['grid'];
|
$gridName = $stateChange['grid'];
|
||||||
$grid = $form->Fields()->dataFieldByName($gridName);
|
$grid = $form->Fields()->dataFieldByName($gridName);
|
||||||
|
|
||||||
$state = $grid->getState(false);
|
$state = $grid->getState(false);
|
||||||
$state->setValue($data['GridState']);
|
if(isset($data['GridState'])) $state->setValue($data['GridState']);
|
||||||
|
|
||||||
$actionName = $stateChange['actionName'];
|
$actionName = $stateChange['actionName'];
|
||||||
|
$args = isset($stateChange['args']) ? $stateChange['args'] : array();
|
||||||
$args = $stateChange['args'];
|
|
||||||
$grid->handleAction($actionName, $args, $data);
|
$grid->handleAction($actionName, $args, $data);
|
||||||
|
|
||||||
switch($request->getHeader('X-Get-Fragment')) {
|
switch($request->getHeader('X-Get-Fragment')) {
|
||||||
|
@ -315,7 +315,7 @@ class GridFieldtest extends SapphireTest {
|
|||||||
$obj = new GridField('testfield', 'testfield', ArrayList::create(), $config);
|
$obj = new GridField('testfield', 'testfield', ArrayList::create(), $config);
|
||||||
$id = 'testGridStateActionField';
|
$id = 'testGridStateActionField';
|
||||||
Session::set($id, array('grid'=>'', 'actionName'=>'jump'));
|
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');
|
$request = new SS_HTTPRequest('POST', 'url');
|
||||||
$obj->gridFieldAlterAction(array('StateID'=>$id), $form, $request);
|
$obj->gridFieldAlterAction(array('StateID'=>$id), $form, $request);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user