2013-02-23 75 views
0

PicCodeIgniter的表單輔助

我有行的表從數據庫中,該表我做一個foreach就像你通常會得到行。圖片在上面。

那麼我的項目需要有表格上的行的操作按鈕,所以我創建了複選框(一切順利)。現在我的問題是,當我點擊提交按鈕,當我的表單由於某種原因完全填寫時,按鈕什麼也不做。我在我的項目的其他頁面中使用了表單助手,沒有任何問題。現在我得到了我的第一個問題。

這是我的表視圖:

<table id='waiting' class='display'> 
    <thead> 
     <tr> 
      <th>ID</th>      
      <th>A Number</th> 
      <th>First Name</th> 
      <th>Last Name</th> 
      <th>Reason for visit</th> 
      <th>Comments</th> 
      <th>Aid Year</th> 
      <th>Staff Comments</th> 
      <th>Staff Member</th> 
      <th>Options</th> 
     </tr> 
    </thead> 
    <tbody> 
     <?php foreach ($waiting as $row) { ?>     
     <tr> 
      <td><?php echo htmlspecialchars($row['id'], ENT_QUOTES, 'UTF-8'); ?></td>    
      <td><?php echo htmlspecialchars($this->encrypt->decode($row['anum']), ENT_QUOTES, 'UTF-8'); ?></td> 
      <td><?php echo htmlspecialchars($row['first'], ENT_QUOTES, 'UTF-8'); ?></td> 
      <td><?php echo htmlspecialchars($row['last'], ENT_QUOTES, 'UTF-8'); ?></td> 
      <td><?php echo htmlspecialchars($row['reason'], ENT_QUOTES, 'UTF-8'); ?></td> 
      <td><?php echo htmlspecialchars($row['studentcomments'], ENT_QUOTES, 'UTF-8'); ?></td> 
      <td><?php echo htmlspecialchars($row['aidyear'], ENT_QUOTES, 'UTF-8'); ?></td> 
      <td><?php echo htmlspecialchars($row['counselorcomments'], ENT_QUOTES, 'UTF-8'); ?></td> 
      <td> 
       <?php echo form_open('studentqueue_controller/counselorscreen'); ?> 
       <?php echo form_dropdown('namedrop', $names) ?></td> 
      <td> 
       <input type="checkbox" name="options" value="start" <?php echo form_checkbox('options','start') ?>Start</input> 
       <input type="checkbox" name="options" value="stop" <?php echo form_checkbox('options','stop') ?>Incactive</input> 
      </td> 
     </tr> 
     <?php } ; ?> 
     <?php echo form_submit('submit', 'Start Action'); ?> 
     <?php echo form_close(); ?> 

我開始在循環開放的形式,因爲我需要在表中的所有行必須給他們一個動作(開始和終止)

我在這裏錯過了什麼?

+0

頁面加載後,HTML的外觀如何? – Stenerson 2013-02-23 14:51:37

+0

html的表格在原始文章中。實際的代碼在這裏:http://pastebin.com/Y0hxiaQY – RaGe10940 2013-02-23 14:57:18

回答

0
<h3>Students Waiting</h3> 
       <table id='waiting' class='display'> 
        <thead> 
         <tr> 
          <th>ID</th>      
          <th>A Number</th> 
          <th>First Name</th> 
          <th>Last Name</th> 
          <th>Reason for visit</th> 
          <th>Comments</th> 
          <th>Aid Year</th> 
          <th>Staff Comments</th> 
          <th>Staff Member</th> 
          <th>Options</th> 
         </tr> 
        </thead> 
        <tbody> 

         <?php 
         foreach ($waiting as $row) 
         { 
          ?>     
         <tr> 
          <td><?php echo htmlspecialchars($row['id'], ENT_QUOTES, 'UTF-8'); ?></td>    
          <td><?php echo anchor('studentqueue_controller/history/'.urlencode($row['anum']). '', $row['anum'], 'target="_blank"'); ?></td> 
          <td><?php echo htmlspecialchars($row['first'], ENT_QUOTES, 'UTF-8'); ?></td> 
          <td><?php echo htmlspecialchars($row['last'], ENT_QUOTES, 'UTF-8'); ?></td> 
          <td><?php echo htmlspecialchars($row['reason'], ENT_QUOTES, 'UTF-8'); ?></td> 
          <td><?php echo htmlspecialchars($row['studentcomments'], ENT_QUOTES, 'UTF-8'); ?></td> 
          <td><?php echo htmlspecialchars($row['aidyear'], ENT_QUOTES, 'UTF-8'); ?></td> 
          <td><?php echo htmlspecialchars($row['counselorcomments'], ENT_QUOTES, 'UTF-8'); ?></td> 
          <td> 
           <?php echo form_open('studentqueue_controller/counselorscreen'); ?> 
           <?php echo form_dropdown('namedrop', $names) ?></td> 
          <td> 
           <input type="checkbox" name="options" value="start" <?php echo form_checkbox('options','start') ?>Start</input> 
           <br /> 
           <input type="checkbox" name="options" value="stop" <?php echo form_checkbox('options','stop') ?>Delete</input> 
           <?php echo form_submit('submit', 'Start Action'); ?>       
           <?php echo form_close(); ?> 
          </td> 
         </tr> 

         <?php 
         } ?> 
        </tbody>  
       </table> 

我把form_open和form都放在了foreach中,並且做了個訣竅。

0

您打開表單兩次,所以第二個之前的所有內容都被忽略。 刪除此行:

<?php echo form_open('studentqueue_controller/counselorscreen'); ?> 

從剛纔的namedrop之前,它應該是罰款。看看你的pastebin,第51行和第83行都是打開相同的表單。

+0

正確的形式是在每個循環,因爲表中的每一行都有自己的形式(這是意圖) – RaGe10940 2013-02-23 16:22:44