2

我必须在清单中显示有一个关系表数据。我正在为列表视图使用 CakePHP 分页和搜索功能。其余所有功能都运行良好,但我无法为相关表字段提供排序功能。

我正在使用

<th><?php echo $this->Paginator->sort('First Name','Enrollment.first_name');?></th>
<th><?php echo $this->Paginator->sort('Last Name','Enrollment.last_name');?></th>
<th><?php echo $this->Paginator->sort('Product','Product.name');?></th>

但是对产品进行分类不起作用。

4

1 回答 1

0
<th><?php echo $this->Paginator->sort('First Name','Enrollment.first_name');?></th>
<th><?php echo $this->Paginator->sort('Last Name','Enrollment.last_name');?></th>
<th><?php echo $this->Paginator->sort('Product','Product.name');?></th>

......

<td>
   <?php echo $this->Html->link($YOURVAR['Enrollment']['first_name'], array('controller' => 'enrollments', 'action' => 'view', $YOURVAR['Enrollment']['id'])); ?>
</td>
<td>
  <?php echo $this->Html->link($YOURVAR['Enrollment']['title'], array('controller' => 'enrollments', 'action' => 'view', $YOURVAR['Enrollment']['id'])); ?>
</td>
<td>

  // Checkout this line that you change the line as following
  <?php echo $this->Html->link($YOURVAR['Product']['name'], array('controller' => 'products', 'action' => 'view', $YOURVAR['Product']['id'])); ?>
</td>
于 2012-04-12T08:30:33.623 回答