2013-10-04 29 views
0

我有以下作用:CakePHP的價值心不是發送到動作

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> 

回答

1
$websites['Website']['website_id'] 

,而不是

$website['Website']['website_id'] 

(複數而不是單數)

編輯:看到你的整個代碼

$site['Website']['website_id'] 
+0

這不是問題,我會發布我的全視圖在這裏,所以你可以看到..該鏈接正在生成一個循環 – Marc

+0

SOOO失敗我剛剛意識到問題是,它不是$網站它的$網站!你是對的! – Marc

+1

so:'$ site ['Website'] ['website_id']'。 – arilia

1

在後您$this->Html->link設置'action' => 'website_status' 是它應該是admin_website_status?

還要確保$website['Website']['website_id']有一個值。也許它是空的。

+0

我100%確定它有一個值,因爲我可以調試它。 – Marc

+0

SOOO失敗我剛剛意識到問題是它的$網站其$站點!你是對的!抱歉!你知道我可以發送兩個值而不是一個嗎? – Marc