商店功能控制器未获得价值

时间:2019-07-07 06:55:42

标签: javascript php jquery laravel laravel-5

即时通讯尝试在laravel中使用动态表保存数据。 如果没有数据,则在创建新数据时,该行将成功保存。 但是当我尝试添加新行时,出现此错误:

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()">&#xE03B;</i></a>
                <a class="edit" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;
</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">&#xE254;</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()"

但是操作链接无法获取baseurl,如下所示 enter image description here

更新,我更改了已经显示的javascript和url中的路由,但是现在我收到错误页面过期。

0 个答案:

没有答案