I have the following model in a CakePHP 1.2 app:
class Equipment extends AppModel {
var $name = 'Equipment';
var $belongsTo=array("City");
///
}
And my City model looks like this:
class City extends AppModel {
var $name = 'City';
var $belongsTo=array("State");
///
}
I'm not doing anything special in the EquipmentController -- just getting all the equipment with a Paginator.
So when I try to implement the pagination in the view like this:
<th><?php echo $paginator->sort('Equipment',"Equipment.name");?></th>
<th><?php echo $paginator->sort('City',"City.name");?></th>
<th><?php echo $paginator->sort('State',"State.name");?></th>
I can sort by Equipment name and City name, but sorting by State name gives me a sorted list by the City.id -- not the State.name. I've tried using City.State.name, but that gave me the same result. I've change the "recursive" property on both models to "2", with the same result.
);
Why does this not work? Can anyone give me a work-around or show me what I am doing wrong?
EDIT I forgot to say that I tried Containable, which did not work either. This is how I set it up:
$this->paginate = array(
"conditions" => array("Equipment.expire_time >"=>date("Y-m-d H:i:s"),
"Equipment.is_active"=>true
),
'limit' => 25,
'order' => array(
'Equipment.available_time' => 'asc',
),
'contain'=>array(
"City"=>array(
"fields"=>array("id","name"),
"State"=>array("fields"=>"name")),
)
And I see the proper queries running, but still can sort by State