2013-04-11 76 views
0

我有一個包含數據的訂單。在提交控制器功能new_blank_order_summary被調用。用codeigniter接收發布信息

的語法是這樣的:

function new_blank_order_summary() 
    { 
     echo "orderlines: ".$this->input->post(orderlines); 
     echo "customer: ".$this->input->post('customer'); 
     echo "period: ".$this->input->post('period'); 
     echo "creditlimit: ".$this->input->post('creditlimit'); 

     $this->load->view('sales/new_blank_order_summary'); 

    } 

我不能得到這個職位信息顯示或回聲?我的輸入名稱和ID是orderlines,但未被正確發佈或接收。

「愚蠢」問題的道歉。

任何意見歡迎。

HTML

<form id="sales_blank_order_details" action="/sales/new_blank_order_summary" method="post"> 


      <table > 
       <tr><td>Customer</td><td>Period</td><td>UoM</td><td>Credit Limit</td><td>Balance</td><td>New Balance</td><td>Order Lines</td><td>Round to Bundle</td></tr> 
        <tr><td> 
      <input type="text" name="customer" id="customer" value="<?php echo $customer; ?>" disabled> 
       </td><td> 
      <input type="text" name="period" id="period" value="<?php echo $period." to ".$newperiod; ?>" disabled> 
       </td><td> 
      <input type="text" name="buom" id="buom" value="<?php echo $buom; ?>" disabled> 
       </td><td> 
      <input type="text" name="creditlimit" id="creditlimit" value="<?php echo $creditlimit['creditlimit']; ?>" disabled> 
      </td><td> 
      <input type="text" name="currentbalance" id="currentbalance" value="<?php echo $creditlimit['currentbalance']; ?>" disabled> 
      </td> 
      <td> 
      <input type="text" name="newbalance" id="newbalance" value="<?php echo $creditlimit['currentbalance']; ?>" disabled> 
      </td><td> 
      <input type="text" name="orderlines" id="orderlines" value="1" disabled> 
      </td><td> 
      <input type="checkbox" name="rounduptobundle" id="rounduptobundle" checked> 
      </td></tr></table> 

<input type="submit" name="blank_order_lines" id="blank_order_lines" value="Save Order and Proceed"> 

</form> 

這些職位中沒有由控制器輸出。

+0

'有序'具有雙s? – Mudshark 2013-04-11 11:50:12

+0

抱歉Mudshark,錯字:-) – Smudger 2013-04-11 11:56:02

+0

表單html是什麼樣的? – Mudshark 2013-04-11 12:02:12

回答

2

您已禁用orderlines文本輸入字段,這就是爲什麼它不會發布。刪除disabled,它將顯示在$this->input->post()

+0

所以禁用的輸入不會發布?如何阻止用戶編輯它們並仍然發佈它們?他們需要顯示如此隱藏不會工作。 – Smudger 2013-04-11 12:13:50

+1

你可以添加一個隱藏字段,其中name =「orderlines」value =「1」'這將顯示在後 - (禁用)可見文本字段在這種情況下不需要'name',它只是作爲視覺反饋給用戶。 – Mudshark 2013-04-11 12:17:02

1

提交按鈕的名稱和價值是什麼。通常,我提交按鈕的名稱是name =「submit」,值是value =「submit」。那麼我試試$ this-> input-> post('submit')=='submit'。在你的條件下試試這個。我希望它會起作用。祝你好運。

+0

謝謝eddard,if語句正在工作,但是orderlines的帖子不是。我可以在條件內放置一個'echo'test'',它會正確顯示。再次感謝。 – Smudger 2013-04-11 11:57:50

0
function new_blank_order_summary() 
{ 
     echo "orlderlines: ".$this->input->post('orderlines'); 
     echo "customer: ".$this->input->post('customer'); 
     echo "period: ".$this->input->post('period'); 
     echo "creditlimit: ".$this->input->post('creditlimit'); 

     $this->load->view('sales/new_blank_order_summary'); 

} 

請試試這段代碼。我沒有改變它的一條線。只有我把單引號放在第三行。並且,改變它的變量名稱是錯誤的,所以我改變了它