doushizhou4477 2019-07-07 06:55
浏览 39

存储功能控制器没有获得价值

im triying to save data with dynamic table in laravel. If there isnt data, when im creating new one, the row successfully save. but when im trying to add new row i get this error:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'description' cannot be null

i have declare the input element name on js as name="description", but still error.

This is my 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();
    });

This is my table:

<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>

And this is my Controller:

public function storeAboutList(Request $request)
    {
        Quote::create([
            'section'       => "About",
            'description'   => $request->description 
        ]);
    }

Edit: i have update code in table from onclick="document.getElementById('aboutForm1').submit()" to onclick="document.getElementById('aboutForm').submit()"

but action link cant get baseurl like below enter image description here

Update, i change route in javascript and url already shown, but now i get error Page Expired.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序
    • ¥15 多址通信方式的抗噪声性能和系统容量对比