http://webdesign4.georgianc.on.ca/~100141468/comp2084/todo/clients
问题:http://webdesign4.georgianc.on.ca/~100141468/comp2084/todo/timesheets/filter2/7
这必须是一个小写变量或其他问题,但我无法理解。 Filter2.ctp IDnameHoursclientsedit
<? foreach($Timesheets as $row): ?>
<tr><td>
<?=$row['Timesheet']['id']?>
</td><td>
<?=$row['Timesheet']['hours']?>
</td><td>
<a href="../../clients/view/<?=$row['client']['name']?>"><?=$row['client]['name']?></a>
</td><td>
<a href="edit/<?=$row['Timesheet']['id']?>">Edit</a>
</td></tr>
<? endforeach; ?>
</table>
Timesheetcontroller filter2
function filter2($Client_id) {
$this->set('Timesheets',$this->Timesheet->findAllByClientId($Client_id));
}
答案 0 :(得分:2)
在这一行
<a href="../../clients/view/<?=$row['client']['name']?>"><?=$row['client]['name']?></a>
您错过了'
。这会产生语法错误。您可能还需要将'Client'
索引大写以获得所需的结果,因为它是模型的名称。 view
中的ClientsController
操作也可能需要ID。您可以将其更改为:
<a href="../../clients/view/<?=$row['Client']['id']?>"><?=$row['Client']['name']?></a>
但是,我建议不要像这样硬编码网址,但让Cake生成这样的链接:
<?= $this->Html->link($row['Client']['name'], array('controller' => 'clients', 'action' => 'view', $row['Client']['id']) ?>