[英]Laravel request always return null
So i have this view所以我有这个观点
<form method="POST" action="/store">
<div class="control-group after-add-more">
<div class="form-group">
<label>Partner :</label>
<input type="text" class="form-control" id="partner" name="partner" value="" placeholder="Partner Name" />
</div>
<button class="btn btn-success add-more" type="button">
<i class="glyphicon glyphicon-plus"></i> Plus Partner</button>
<div class="copy hide">
<div class="control-group">
<div class="form-group">
<label> Partner :</label>
<input type="text" class="form-control" id="partner2" name="partner2" value="" placeholder="Partner Name" />
</div>
<button class="btn btn-danger remove" type="button">
<i class="glyphicon glyphicon-remove"></i>
Delete Partner</button>
</div>
</div>
<button type="submit">Submit</button>
</form>
this is jquery that i use这是我使用的 jquery
$(document).ready(function() {
$(".add-more").click(function() {
var html = $(".copy").html();
$(".after-add-more").after(html);
});
$("body").on("click", ".remove",function() {
$(this).parents(".control-group").remove();
});
});
but when i try to submit, the input partner2 is returning null value但是当我尝试提交时,输入 partner2 返回 null 值
this is my controller这是我的 controller
$kerma = Kerma::find(1)->get();
$kerma->partner()->createMany(['partner' => $request->input('partner')],['partner' => $request->input('partner2')])
anyone have a solution for me?有人能给我解决方案吗? thanks in advance
提前致谢
When submitting your request to the form:向表单提交请求时:
POST
method configured.POST
方法。Route::post('store', 'YourController@yourmethod');
Page Expired
issue.Page Expired
问题。 So, your blade file should be like below:<form method="POST" action="{{url('store')}}">
@csrf
<div class="control-group after-add-more">
<div class="form-group">
<label>Partner :</label>
<input type="text" class="form-control" id="partner" name="partner" value="" placeholder="Partner Name" />
</div>
<button class="btn btn-success add-more" type="button">
<i class="glyphicon glyphicon-plus"></i> Plus Partner</button>
<div class="copy hide">
<div class="control-group">
<div class="form-group">
<label> Partner :</label>
<input type="text" class="form-control" id="partner2" name="partner2" value="" placeholder="Partner Name" />
</div>
<button class="btn btn-danger remove" type="button">
<i class="glyphicon glyphicon-remove"></i>
Delete Partner</button>
</div>
</div>
<button type="submit">Submit</button>
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.