Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

When you are showing a related model field in paginator sort it will …

…display more friendly. eg: $this->Paginator->sort('Text.label') will retorn as Text Label
  • Loading branch information...
commit 00ea4273832d34c18a528f863713f7a5631c9214 1 parent 4bdaa2b
@krolow krolow authored
View
13 lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
@@ -243,7 +243,7 @@ public function testSortLinkWithVirtualField() {
$result = $this->Paginator->sort('Article.full_name');
$expected = array(
'a' => array('href' => '/accounts/index/page:1/sort:Article.full_name/direction:desc', 'class' => 'asc'),
- 'Article.full Name',
+ 'Article Full Name',
'/a'
);
$this->assertTags($result, $expected);
@@ -260,7 +260,7 @@ public function testSortLinkWithVirtualField() {
$result = $this->Paginator->sort('Article.full_name');
$expected = array(
'a' => array('href' => '/accounts/index/page:1/sort:Article.full_name/direction:asc', 'class' => 'desc'),
- 'Article.full Name',
+ 'Article Full Name',
'/a'
);
$this->assertTags($result, $expected);
@@ -320,6 +320,15 @@ public function testSortLinksUsingDotNotation() {
));
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
+ $result = $this->Paginator->sort('Article.title');
+ $expected = array(
+ 'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:asc', 'class' => 'desc'),
+ 'Article Title',
+ '/a'
+ );
+ $this->assertTags($result, $expected);
+
+ $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
$result = $this->Paginator->sort('Article.title', 'Title');
$expected = array(
'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:asc', 'class' => 'desc'),
View
5 lib/Cake/View/Helper/PaginatorHelper.php
@@ -315,6 +315,11 @@ public function sort($key, $title = null, $options = array()) {
if (empty($title)) {
$title = $key;
+
+ if (strpos($title, '.') !== false) {
+ $title = str_replace('.', ' ', $title);
+ }
+
$title = __(Inflector::humanize(preg_replace('/_id$/', '', $title)));
}
$dir = isset($options['direction']) ? $options['direction'] : 'asc';
Please sign in to comment.
Something went wrong with that request. Please try again.