我有这个表格
<div class="row">
<div class="col-lg-8 offset-2">
<form class="form-signin" method="POST">
{{ csrf_field() }}
<div class="form-label-group mt-1">
<label class="text-dark-orange" for="name">Naam</label>
<input type="text" id="name" name="name" class="form-control sentje-inputfield-payment" placeholder="Vul hier uw naam in" required>
</div>
<div class="form-label-group mt-1">
<label class="text-dark-orange" for="note">Notitie</label>
<textarea type="text" id="note" name="note" class="form-control sentje-inputfield-payment" placeholder="Vul hier eventueel een notitie in"></textarea>
</div>
</div>
</div>
<div class="row mt-5">
<div class="col-lg-8 offset-2">
<a href="{{ route('paymentrequest.preparePayment', [$paymentrequest->unique_link, $paymentrequest]) }}"><button type="submit" class="btn btn-block btn-lg sentje-button">Betalen</button></a>
</form>
</div>
</div>
当我点击按钮时,它会发送 $paymentrequest
。 (我已经将该参数发送到 View )我将如何传递已放入表单中的数据?
最佳答案
为您的表单提供一个 ID 并执行
<a>
的操作网址:<form action="{{ route('paymentrequest.preparePayment', [$paymentrequest->unique_link, $paymentrequest]) }}" id="my-form" class="form-signin" method="POST">
更改您的
<a>
只是button
与type="submit"
和一个form="<form-id>"
<button type="submit" form="my-form" class="btn btn-block btn-lg sentje-button">Betalen</button>
使用表单属性允许您关闭表单标签并将按钮放在外面,并且允许您仍然提交它并使代码更整洁。
关于php - 如何使用其他变量在路由中传递表单数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55379974/