dongtiannai0654 2017-03-06 11:25
浏览 7

从编辑到更新如何在它们之间进行链接?

I'm trying to get from my edit page to my update page but there is nothing in the documentation that's explaining how to route to it. This is my form on my edit page:

/*
Or method="PUT"
*/
<form method="PATCH" action="../{{$id}}">
{{ method_field('PUT') }}
<input type="submit" value="edit"/>
</form>

My routes is being declared as a resource controller:

Routes::resource('/','TestController',['parameters' => [
    '' => 'test'
]]);

In my controller I just have:

public function update(Request $request, Test $test){
    return 'test';
}

It's just giving me different errors when trying to access the update action in multiple ways.

I tried: {{route($id)}} which gives me:

Route 1 not defined

The resource documentation gives me that the url is suppose to be like this:

PUT/PATCH   /photos/{photo} 

I dont understand the routing of resource controllers in laravel and theres not a lot to find about it. I even tried to simply go 1 back from /{{$id}}/edit like this: ../{{$id}}but that just brings me to the show action(since show and update have the same url apparently) and I also think this isnt the best way to access an action from the controller.

  • 写回答

2条回答 默认 最新

  • dpn4073 2017-03-06 11:31
    关注

    Try changing your form opening tag to be:

    <form method="POST" action="{{ url($id) }}">
        {{ csrf_field() }}
        {{ method_field('PUT') }}
    

    Hope this helps!

    评论

报告相同问题?

悬赏问题

  • ¥15 对于知识的学以致用的解释
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败