我有以下行动:
public function admin_website_status($id = null){
$i = 0;
$this->Paginator->settings = array(
'Website' => array(
)
);
$this->set('websites',$this->Paginator->paginate('Website'));
}
现在我想向此操作发送一个值,因此在我看来,我有以下链接:
<?php echo $this->Html->link(__('Active'), array('action' => 'website_status', $website['Website']['website_id'])); ?>
当我调试时,即使我知道该值应为1
那么我做错了什么?
我的完整视图
<div class="portlet box red">
<div class="portlet-title">
<div class="caption"><i class="icon-globe"></i>Website Status</div>
</div>
<div class="portlet-body">
<table class="table table-striped table-bordered table-hover table-full-width" id="sample_1">
<thead>
<tr>
<th><?php echo $this->Paginator->sort('Website.domain', 'Website domain');?></th>
<th><?php echo $this->Paginator->sort('Website.client_id', 'Affiliate ID');?></th>
<th><?php echo $this->Paginator->sort('User.username', 'E-mail Address');?></th>
<th><?php echo $this->Paginator->sort('Status.status', 'Status'); ?> </th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
</thead>
<?php foreach ($websites as $site): ?>
<tr>
<td><?php echo $site['Website']['domain']; ?></td>
<td><?php echo $site['Client']['client_id'];?></td>
<td><?php echo $site['Client']['user_id'];?></td>
<td><?php echo $site['Status']['Status']; ?></td>
<td class="actions">
<?php echo $this->Html->link(__('Active'), array('action' => 'website_status', $website['Website']['website_id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<div class="paging">
<?php
echo $this->Paginator->prev('« Previous', null, null, array('class' => 'disabled'));
echo $this->Paginator->next('Next »', null, null, array('class' => 'disabled'));
?>
</div>
</div>
答案 0 :(得分:1)
$websites['Website']['website_id']
而不是
$website['Website']['website_id']
(复数而非单数)
编辑:看完整个代码后
$site['Website']['website_id']
答案 1 :(得分:1)
在$this->Html->link
中设置'action' => 'website_status'
它应该是admin_website_status吗?
还要确保$website['Website']['website_id']
有值。也许它是空的。