mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '3.4' into 3
This commit is contained in:
commit
4c40cf8dbb
@ -37,7 +37,7 @@ display up to two levels of tabs in the interface. If you want to group data fur
|
|||||||
## Moving a field between tabs
|
## Moving a field between tabs
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
$field = $fields->dataFieldByName('Content');
|
$content = $fields->dataFieldByName('Content');
|
||||||
|
|
||||||
$fields->removeFieldFromTab('Root.Main', 'Content');
|
$fields->removeFieldFromTab('Root.Main', 'Content');
|
||||||
$fields->addFieldToTab('Root.MyContent', $content);
|
$fields->addFieldToTab('Root.MyContent', $content);
|
||||||
|
@ -551,19 +551,19 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler {
|
|||||||
$list->add($this->record, $extraData);
|
$list->add($this->record, $extraData);
|
||||||
} catch(ValidationException $e) {
|
} catch(ValidationException $e) {
|
||||||
$form->sessionMessage($e->getResult()->message(), 'bad', false);
|
$form->sessionMessage($e->getResult()->message(), 'bad', false);
|
||||||
|
if ($controller->getRequest()->isAjax()) {
|
||||||
$responseNegotiator = new PjaxResponseNegotiator(array(
|
$responseNegotiator = new PjaxResponseNegotiator(array(
|
||||||
'CurrentForm' => function () use (&$form) {
|
'CurrentForm' => function () use (&$form) {
|
||||||
return $form->forTemplate();
|
return $form->forTemplate();
|
||||||
},
|
},
|
||||||
'default' => function() use(&$controller) {
|
|
||||||
return $controller->redirectBack();
|
|
||||||
}
|
|
||||||
));
|
));
|
||||||
if($controller->getRequest()->isAjax()){
|
|
||||||
$controller->getRequest()->addHeader('X-Pjax', 'CurrentForm');
|
$controller->getRequest()->addHeader('X-Pjax', 'CurrentForm');
|
||||||
}
|
|
||||||
return $responseNegotiator->respond($controller->getRequest());
|
return $responseNegotiator->respond($controller->getRequest());
|
||||||
}
|
}
|
||||||
|
Session::set("FormInfo.{$form->FormName()}.errors", array());
|
||||||
|
Session::set("FormInfo.{$form->FormName()}.data", $form->getData());
|
||||||
|
return $controller->redirectBack();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Save this item into the given relationship
|
// TODO Save this item into the given relationship
|
||||||
|
|
||||||
|
@ -360,7 +360,8 @@ class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Sorta
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse column specification, considering possible ansi sql quoting
|
// Parse column specification, considering possible ansi sql quoting
|
||||||
if(preg_match('/^"?(?<column>[^"\s]+)"?(\s+(?<direction>((asc)|(desc))(ending)?))?$/i', $column, $match)) {
|
// Note that table prefix is allowed, but discarded
|
||||||
|
if(preg_match('/^("?(?<table>[^"\s]+)"?\\.)?"?(?<column>[^"\s]+)"?(\s+(?<direction>((asc)|(desc))(ending)?))?$/i', $column, $match)) {
|
||||||
$column = $match['column'];
|
$column = $match['column'];
|
||||||
if(empty($direction) && !empty($match['direction'])) {
|
if(empty($direction) && !empty($match['direction'])) {
|
||||||
$direction = $match['direction'];
|
$direction = $match['direction'];
|
||||||
|
@ -274,6 +274,30 @@ class ArrayListTest extends SapphireTest {
|
|||||||
array('Name' => 'Steve')
|
array('Name' => 'Steve')
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Quoted name name with table
|
||||||
|
$list4 = $list->sort('"Record"."Name"');
|
||||||
|
$this->assertEquals($list4->toArray(), array(
|
||||||
|
(object) array('Name' => 'Bob'),
|
||||||
|
array('Name' => 'John'),
|
||||||
|
array('Name' => 'Steve')
|
||||||
|
));
|
||||||
|
|
||||||
|
// Quoted name name with table (desc)
|
||||||
|
$list5 = $list->sort('"Record"."Name" DESC');
|
||||||
|
$this->assertEquals($list5->toArray(), array(
|
||||||
|
array('Name' => 'Steve'),
|
||||||
|
array('Name' => 'John'),
|
||||||
|
(object) array('Name' => 'Bob')
|
||||||
|
));
|
||||||
|
|
||||||
|
// Table without quotes
|
||||||
|
$list6 = $list->sort('Record.Name');
|
||||||
|
$this->assertEquals($list6->toArray(), array(
|
||||||
|
(object) array('Name' => 'Bob'),
|
||||||
|
array('Name' => 'John'),
|
||||||
|
array('Name' => 'Steve')
|
||||||
|
));
|
||||||
|
|
||||||
// Check original list isn't altered
|
// Check original list isn't altered
|
||||||
$this->assertEquals($list->toArray(), array(
|
$this->assertEquals($list->toArray(), array(
|
||||||
array('Name' => 'Steve'),
|
array('Name' => 'Steve'),
|
||||||
|
Loading…
Reference in New Issue
Block a user