Reputation: 91
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
$(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
this is my 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
Upvotes: 1
Views: 625
Reputation: 5476
When submitting your request to the form:
POST
method configured.Route::post('store', 'YourController@yourmethod');
Page Expired
issue. 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>
Upvotes: 1