From 9b1a4b328c6dbab421081509772e85cbee5b1e27 Mon Sep 17 00:00:00 2001 From: Ironcheese Date: Wed, 15 Jun 2016 15:36:43 +0200 Subject: [PATCH 1/3] Moving a field between tabs, wrong variable name --- docs/en/02_Developer_Guides/03_Forms/06_Tabbed_Forms.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/02_Developer_Guides/03_Forms/06_Tabbed_Forms.md b/docs/en/02_Developer_Guides/03_Forms/06_Tabbed_Forms.md index c958749a8..f2826de0d 100644 --- a/docs/en/02_Developer_Guides/03_Forms/06_Tabbed_Forms.md +++ b/docs/en/02_Developer_Guides/03_Forms/06_Tabbed_Forms.md @@ -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 :::php - $field = $fields->dataFieldByName('Content'); + $content = $fields->dataFieldByName('Content'); $fields->removeFieldFromTab('Root.Main', 'Content'); $fields->addFieldToTab('Root.MyContent', $content); @@ -52,4 +52,4 @@ display up to two levels of tabs in the interface. If you want to group data fur ## API Documentation -* [api:FormScaffolder] \ No newline at end of file +* [api:FormScaffolder] From 24efc7edf83bb06b5a01080d2742c07ef68d21b2 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Tue, 12 Jul 2016 17:00:17 +1200 Subject: [PATCH 2/3] BUG Fix sorting ArrayList with sql-like syntax Replaces #5726 --- model/ArrayList.php | 5 +++-- tests/model/ArrayListTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/model/ArrayList.php b/model/ArrayList.php index 21db8740d..7ece7c988 100644 --- a/model/ArrayList.php +++ b/model/ArrayList.php @@ -360,7 +360,8 @@ class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Sorta } // Parse column specification, considering possible ansi sql quoting - if(preg_match('/^"?(?[^"\s]+)"?(\s+(?((asc)|(desc))(ending)?))?$/i', $column, $match)) { + // Note that table prefix is allowed, but discarded + if(preg_match('/^("?(?[^"\s]+)"?\\.)?"?(?[^"\s]+)"?(\s+(?((asc)|(desc))(ending)?))?$/i', $column, $match)) { $column = $match['column']; if(empty($direction) && !empty($match['direction'])) { $direction = $match['direction']; @@ -448,7 +449,7 @@ class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Sorta } $multisortArgs[] = &$originalKeys; - + $list = clone $this; // As the last argument we pass in a reference to the items that all the sorting will be applied upon $multisortArgs[] = &$list->items; diff --git a/tests/model/ArrayListTest.php b/tests/model/ArrayListTest.php index 1f91a58d6..963d676aa 100644 --- a/tests/model/ArrayListTest.php +++ b/tests/model/ArrayListTest.php @@ -274,6 +274,30 @@ class ArrayListTest extends SapphireTest { 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 $this->assertEquals($list->toArray(), array( array('Name' => 'Steve'), From 3482c98ccecc0d52e556669b230b977d7b81a45f Mon Sep 17 00:00:00 2001 From: zauberfisch Date: Wed, 13 Jul 2016 09:34:02 +0000 Subject: [PATCH 3/3] only use PjaxResponseNegotiator in GridFieldDetailForm if the Request is actually AJAX (fixes #5801) --- forms/gridfield/GridFieldDetailForm.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/forms/gridfield/GridFieldDetailForm.php b/forms/gridfield/GridFieldDetailForm.php index 5eeabcfcb..29802323e 100644 --- a/forms/gridfield/GridFieldDetailForm.php +++ b/forms/gridfield/GridFieldDetailForm.php @@ -549,18 +549,18 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler { $list->add($this->record, $extraData); } catch(ValidationException $e) { $form->sessionMessage($e->getResult()->message(), 'bad', false); - $responseNegotiator = new PjaxResponseNegotiator(array( - 'CurrentForm' => function() use(&$form) { - return $form->forTemplate(); - }, - 'default' => function() use(&$controller) { - return $controller->redirectBack(); - } - )); - if($controller->getRequest()->isAjax()){ + if ($controller->getRequest()->isAjax()) { + $responseNegotiator = new PjaxResponseNegotiator(array( + 'CurrentForm' => function () use (&$form) { + return $form->forTemplate(); + }, + )); $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