【问题标题】:Updating data with bootstrap modal使用引导模式更新数据
【发布时间】:2019-08-03 01:56:31
【问题描述】:

我正在尝试使用引导模式编辑数据。我正在使用 a href 标记传递 3 个数据。我已经设法将数据发送到模式,但是当单击更新时,结果返回 null。

刀片

<a href="#" class="text-primary" data-toggle="modal" data-target="#editRoomModal" data-target="editRoomModal"  data-name="{{$data->name}}" data-max="{{$data->max_occupancy}}" data-id="{{$data->id}}"><i class="fas fa-edit fa-fw"></i></a> 

<script>
    $(document).ready(function(){
    $('#editRoomModal').on('show.bs.modal',function(e){
        var link = $(e.relatedTarget),
            modal = $(this),
            id = link.data("id"),
            name = link.data("name"),
            max = link.data("max");

            modal.find('#name').val(name);
            modal.find('#max_occupancy').val(max);
            modal.find('#id').val(id);
        });
});
</script>

控制器

public function editRoom(Request $request)
{
    $room = Room::where('id',$request->roomid)->first();
    dd($room);
}

【问题讨论】:

  • 你没有将 roomid 传递给控制器​​

标签: php laravel modal-dialog edit


【解决方案1】:

您没有通过 roomid 您将 id 传递给控制器​​请使用此代码,我希望它能解决您的问题

public function editRoom(Request $request)
{
$room = Room::where('id',$request->id)->first();
dd($room);
}

【讨论】:

    猜你喜欢
    • 2021-08-29
    • 2016-04-07
    • 1970-01-01
    • 1970-01-01
    • 2018-03-29
    • 1970-01-01
    • 2019-08-18
    • 1970-01-01
    • 2017-05-08
    相关资源
    最近更新 更多