sorting - CakePHP 2.4.4 Unable to sort/order by virtual field with paginate (Paginator) -


my virtual field property model, generated in beforefind(), called 'distance', works. however, can't sort it. have part of search form:

echo $this->form->input('sort', array(     'options' => hash::get($predefined, 'sort'), // list of options )); 

which adds sort url, , works normal fields, not virtual field distance. should have implemented differently? far i'm aware, virtual fields should work fine pagination.

edit: in case i've implemented pagination wrong...

i've set defaults:

public $paginate = array(     'limit' => 25,     'order' => array(        'properties.id' => 'asc'     ) ); 

after building $conditions:

$this->paginator->settings = $this->paginate; $data = $this->paginator->paginate('property', $conditions); $this->set('properties', $data); 

the above works fine changing order, directly editing /sort:fieldname/ in url, not virtual field 'distance'. tried adding, without success:

$this->paginate['order'] = array($value); //value value 'sort' named parameter 

this part of message:

my virtual field property model, generated in beforefind(),

seems issue.

the virtual field needs defined before call paginate() paginator knows build "sort" criteria.

the beforefind() call happens after pagination call, virtual field not yet defined. moving definition of virtual field right above the pagination call should fix this.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -