My User model belongsTo Department. When looking at a view of Users
I'd like to sort the Department column by the name of the department,
not the department_id.

According to the API for 1.3.5 the appropriate way to do this is:

$this->Paginator->sort(__('Department', true), 'name', array('model'
=> 'Department'));

but this causes the errors included at the bottom of this post (and it
doesn't actually sort; clicking the column head causes it to get
jumbled)

I've also tried the more simple:

$this->Paginator->sort(__('Department', true), 'Department.name');

This doesn't cause errors but the same jumbling upon click (not real
sorting) occurs.

I've tried adding a virtualField to sort on and that works great for
the index view, but the other User views complain that they don't have
access to Department.

These are the errors:

Warning (2)
: array_merge() [http://php.net/function.array-merge]: Argument #2 is
not an array [CORE/cake/libs/view/helpers/paginator.php, line 193]
Code
 |
Context
$model  =       "Department"
$options        =       array()
$params =       null
array_merge - [internal], line ??
PaginatorHelper::sortKey() - CORE/cake/libs/view/helpers/
paginator.php, line 193
PaginatorHelper::sort() - CORE/cake/libs/view/helpers/paginator.php,
line 304
include - APP/views/users/index.ctp, line 14
View::_render() - CORE/cake/libs/view/view.php, line 724
View::render() - CORE/cake/libs/view/view.php, line 419
Controller::render() - CORE/cake/libs/controller/controller.php, line
913
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 207
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 83


Warning (2)
: array_merge() [http://php.net/function.array-merge]: Argument #1 is
not an array [CORE/cake/libs/view/helpers/paginator.php, line 377]
Code
 |
Context
$options        =       array(
        "page" => "1",
        "sort" => "name",
        "direction" => "asc",
        "order" => null
)
$asArray        =       true
$model  =       "Department"
$paging =       null
array_merge - [internal], line ??
PaginatorHelper::url() - CORE/cake/libs/view/helpers/paginator.php,
line 377
PaginatorHelper::link() - CORE/cake/libs/view/helpers/paginator.php,
line 357
PaginatorHelper::sort() - CORE/cake/libs/view/helpers/paginator.php,
line 326
include - APP/views/users/index.ctp, line 14
View::_render() - CORE/cake/libs/view/view.php, line 724
View::render() - CORE/cake/libs/view/view.php, line 419
Controller::render() - CORE/cake/libs/controller/controller.php, line
913
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 207
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 83

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to