2016-01-24 60 views
0

我試圖把我的表單放在foreach中,以便表單中傳遞的值是結果的正確值而不是最後一個值。但表單中的按鈕沒有提交(單擊按鈕後沒有任何反應)。Laravel表單按鈕裏面沒有提交的foreach

<table class="table table-striped table-bordered"> 
      <thead> 
      <tr> 
       <th>Receiver's Name</th> 
       <th>Receiver's Contact</th> 
       <th>Package Type</th> 
       <th>Date Requested</th> 
       </tr> 
      </thead> 

      <tbody class="list"> 

      @foreach($result as $res) 
      <form role="form" method="POST" action="/search "> 
      <input type="hidden" name="requestID" value="{{ $res->id }}"> 
      <tr> 
       <td class="name"> {{ $res->receiverLname }}, 
        {{ $res->receiverFname }}</td> 
       <td class="contact"> {{ $res->receiverContact }} </td> 
       <td class="type"> {{ $res->packType }} </td> 
       <td class="date"> {{ $res->updated_at }} </td> 
       <td><button class="btn"> View Transaction </button></td> 
      </tr> 
      </form> 
      @endforeach 

      </tbody> 

     </table> 

回答

0

沒關係的傢伙。我只是試圖將該值放在按鈕中,而不是在輸入隱藏類型中,並在即時貼中獲得正確的值。 :d

我擺脫了輸入型= 「隱藏」

,讓我的按鈕,這樣

<button class="btn" name="requestID" value="{{ $res->id }}">