SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'description' cannot be null
我已将js上的输入元素名称声明为name =“ description”,但仍然出错。
这是我的javascript:
<script src="{{ asset ('js/core/jquery.3.2.1.min.js') }}"></script>
<script type="text/javascript">
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
var actions = $(".table-bawah td:last-child").html();
// Append table with add row form on add new button click
$(".add-new").click(function(){
$(this).attr("disabled", "disabled");
var index = $(".table-bawah tbody tr:last-child").index();
var row = '<tr>' +
'<form id="aboutForm" action= {{route('quoteabout.store')}} method="post" enctype="multipart/form-data">' +
'@' + 'csrf' +
'<td><input type="text" class="form-control" name="description" id="description"></td>' +
'<td>' + actions + '</td>' +
'</form>'
'</tr>';
$(".table-bawah").append(row);
$(".table-bawah tbody tr").eq(index + 1).find(".add, .edit").toggle();
$('[data-toggle="tooltip"]').tooltip();
});
这是我的桌子:
<table class="table table-bordered-bd-warning table-head-bg-warning table-bawah">
<thead>
<tr>
<th>Description</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@forelse($dataAboutList as $index => $rowAboutList)
<tr>
<form id="aboutForm1" action="{{route('quoteabout.store')}}" method="post" enctype="multipart
/form-data">
@csrf
<td>{{ $rowAboutList->description }}</td>
<td>
<a class="add" title="Add" data-toggle="tooltip"><i class="material-icons" onclick="
document.getElementById('aboutForm1').submit()"></i></a>
<a class="edit" title="Edit" data-toggle="tooltip"><i class="material-icons">
</i></a>
<a class="delete" title="Delete" data-toggle="tooltip"><i class="material-icons">&#x
E872;</i></a>
</td>
</form>
</tr>
@empty
<tr>
<form id="aboutForm" action="{{route('quoteabout.store')}}" method="post" enctype="
multipart/form-data">
@csrf
<td>
<input type="text" class="form-control" id="description" name="description"
placeholder="Isi Judul" required>
</td>
<td>
<a class="add" title="Add" data-toggle="tooltip" style="display: inline-block;" on
click="document.getElementById('aboutForm').submit()"><i class="material-icons">&#x
E03B;</i></a>
<a class="edit" title="Edit" data-toggle="tooltip" style="display: none;"><i class="
material-icons"></i></a>
<a class="delete" title="Delete" data-toggle="tooltip"><i class="material-icons">&#x
E872;</i></a>
</td>
</form>
</tr>
@endforelse
</tbody>
</table>
这是我的控制器:
public function storeAboutList(Request $request)
{
Quote::create([
'section' => "About",
'description' => $request->description
]);
}
编辑:
我在表中有更新代码
onclick="document.getElementById('aboutForm1').submit()"
至
onclick="document.getElementById('aboutForm').submit()"
更新,我更改了已经显示的javascript和url中的路由,但是现在我收到错误页面过期。