2016-01-24 42 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 }}">