【问题标题】:Laravel Form button inside foreach not submittingforeach中的Laravel表单按钮未提交
【发布时间】:2016-01-24 15:09:51
【问题描述】:

我尝试将我的表单放入 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>

【问题讨论】:

    标签: html forms laravel


    【解决方案1】:

    没关系,伙计们。我只是尝试将值放在按钮中而不是输入隐藏类型中,并且我在帖子中获得了正确的值。 :D

    我摆脱了输入 type="hidden"

    并以这种方式制作我的按钮

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-29
      • 1970-01-01
      • 2022-07-05
      • 1970-01-01
      • 2023-04-10
      • 2020-12-03
      • 2015-05-07
      • 1970-01-01
      相关资源
      最近更新 更多