我正在尝试将复选框值放入会话中。当我尝试将其保存在Laravel中时,它会保存复选框的名称字段,例如<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<div class="col-md-3">
<label for="programs">Courses</label>
<div class="input-group">
<select class="form-control" name="program_id" id="program_id">
<option value="">Select</option>
@foreach ($programs as $key=>$p)
<option value="{{ $p->program_id }}">{{ $p->program}}</option>
@endforeach
</select>
<div class="input-group-addon">
<span class="fa fa-plus" id="add-more-program" role="button"></span>
</div>
</div>
</div>
<!-- I have linked the second HTML using modal id selector -->
<div class="modal fade" id="level-show" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" area-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Add Level</h4>
</div>
<form action="{{ route('postInsertLevel' )}}" method="post" id="frm-level-create"></form>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<select name="program_id" id="level_program_id" class="form-control"></select>
</div>
</div>
<div class="row" style="margin-top:30px">
<div class="col-sm-12">
<input type="text" name="level" id="new-level" class="form-control" placeholder="Enter level">
</div>
</div>
<div class="row" style="margin-top:30px">
<div class="col-sm-12">
<input type="text" name="description" id="level-description" class="form-control" placeholder="Enter Description">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary ">Save</button>
</div>
</form>
</div>
</div>
</div>
foo[].
答案 0 :(得分:0)
Session::put('selectsubservice', $subservice->id);
您正在将输入字段的名称作为参数传递给Session :: put,它将不会被自动替换。您需要将实际值传递给Session :: put。