【问题标题】:i m trying to view my edit form. but it gives route missing parameters for update route我正在尝试查看我的编辑表单。但它为更新路线提供了路线缺失的参数
【发布时间】:2019-12-06 10:03:39
【问题描述】:

这是我的代码。 Editpost.blade.php

<form action="{{ route('update_post') }}" method="POST" enctype="multipart/form-data">
    @csrf
    <div class="container">
        <div class="header">
            <h1>Edit Post</h1>
            <p>Please fill in this form to update the post.</p>
        </div>
        <input type="hidden" name="id" value="{{ $post->id }} ">

        <label for="name"><b>Post Name</b></label>
        <input type="text" placeholder="Enter Post Name" name="name" value="{{ $post->name }}"><br><br>

        <label for="link"><b>Post Link</b></label>
        <input type="url" placeholder="Enter Link" name="url" value="{{ $post->url }}"><br><br>

        <label for="image"><b>Post Image</b></label>
        <input type="file" placeholder="Upload Image" name="image" value="{{ $post->image }}"><br><br>

        <input type="submit" value="submit">

        {{--
        <div class="clearfix">
            <button type="submit" class="cancelbtn">Sign Up</button>
            <button type="button" class="signupbtn">Sign In</button>
        </div>
        --}}
    </div>
</form>

web.php

route::get('admin/show-post/edit-post/{id}','MyController@edit_post')->name('edit_post');

route::post('admin/show-post/edit-post/update-post/{id}','MyController@update_post')->name('update_post');

发生了这个错误

Facade\Ignition\Exceptions\ViewException [Route: update_post] [URI: admin/show-post/edit-post/update-post/{id}] 缺少必需的参数。 (查看:C:\wamp64\www\portfolio\resources\views\editpost.blade.php) http://localhost/portfolio/admin/show-post/edit-post/6

【问题讨论】:

  • "缺少 [Route: update_post] [URI: admin/show-post/edit-post/update-post/{id}] 所需的参数" 似乎很明显错误是什么。找到route('update_post') 的用法并添加该参数

标签: laravel-5


【解决方案1】:

你必须修改你的表单动作,传递你想要更新的 id

action="{{ route('update_post', ['id' => $post->id]) }}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-19
    • 2023-03-24
    • 2014-12-28
    • 2021-05-17
    • 1970-01-01
    • 1970-01-01
    • 2017-10-13
    相关资源
    最近更新 更多