Issue
In my application, all index views are sorted by name ASC, by default. I need to order data by ID desc, only after adding a new row, to help the user see the last added row in top of the index.
in controller, add function:
if ($this->Assets->save($asset)) {
$this->Flash->success(__('The asset has been saved.'));
//die('new id:' . $asset->id);
return $this->redirect(['action' => 'index']);
}
This try did not work:
return $this->redirect(['action' => 'index', 'order' => ['id' => 'DESC']]);
what should I do ?
Solution
do you have pagination enabled for your views?
if so the correct link should be
return $this->redirect([
'action' => 'index',
'?' => [
'sort' => 'id',
'direction' => 'desc'
]
]);
Answered By - arilia
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.