代码之家  ›  专栏  ›  技术社区  ›  Yousef Altaf

Laravel 5.4:在提交来自表单弹出式评论模型的数据并将其全部发送之前

  •  1
  • Yousef Altaf  · 技术社区  · 7 年前

    我有一张有两个字段的表格 price order_id 然后 submit 我要做的就是

    • 当用户点击提交按钮时,引导模型弹出窗口并询问用户的意见
    • 用户编写评论并单击提交按钮
    • 接受这些值 价格 我是说, 订单号 comments 把它们送到控制器那里去做任何事情。

    这是我的身体在刀刃上的样子

    {!! Form::open(['route'=>['inline.update.price', $order->id], 'method'=>'patch']) !!}
    {!! Form::text('price', $order->price, ['style'=>'width:100px']) !!}
    {!! Form::hidden('orderListId', $orderList->id) !!}
    <input type="submit" class="btn fa-input updatePriceButton" value="&#xf01b;">
    {!! Form::close() !!}
    

    我想把会议安排得像

    <a href="" class="btn fa-input updatePriceButton" data-toggle="modal" data-target="#supplierComments">
    <i class="fa fa-arrow-circle-up"></i>
    {{ Session::put(['orderId' => $order->id]) }}
    </a>
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   DsRaj    7 年前

    根据评论中的讨论:

    当你提交第一张表格时打开模型,

    从用户那里获取意见,然后通过ajax提交整个表单 检查这个:

    $(document).on('click', '#submit-btn', function() {
        var comment = $("#comment").val();
    	var data = $('#mainForm').serialize()+ "&comment="+comment;
        console.log(data);
    });
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>Example</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>
    <body>
    
    <div class="container">
      <form method="POST" action="/" accept-charset="UTF-8" id="mainForm">
        <input name="_method" type="hidden" value="PATCH"><input name="_token" type="hidden" value="YSEKhNUe8Zh6Q9Xju9nfGBeB2QD1Q7XFS6E4Ssoy">
        <input style="width:100px" name="price" type="text" value="">
        <input name="orderListId" type="hidden" value="">
      </form>
      <a href="" class="btn fa-input updatePriceButton" data-toggle="modal" data-target="#supplierComments">
      <i class="fa fa-arrow-circle-up"></i>
      Submit
      </a>
      <!-- Trigger the modal with a button -->
      <!-- Modal -->
      <div class="modal fade" id="supplierComments" role="dialog">
        <div class="modal-dialog modal-sm">
        
          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title">Modal Header</h4>
            </div>
            <div class="modal-body">
              Comment
              <input type="text" id="comment">
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal" id="submit-btn">Submit</button>
            </div>
          </div>
          
        </div>
      </div>
      
    </div>
    
    </body>
    </html>