簡體   English   中英

laravel 5.4:從表單彈出注釋模型提交數據然后將其全部發送出去之前

[英]laravel 5.4: before submitting data from form popup comments model and then send them all

我有一個包含2個字段priceorder_id的表格,那么我需要做的所有submit按鈕是

  • 當用戶單擊“提交”按鈕時,會彈出引導模型並詢問他的評論
  • 用戶寫評論並單擊提交按鈕
  • 獲取這些值priceorder_idcomments ,並將它們發送到控制器,然后在該處執行任何操作。

這是我的表格在刀片中的外觀

{!! 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>

根據評論中的討論:

提交第一個表單時,打開模型,

從用戶那里獲取輸入以發表評論,然后通過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> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM