How to use update Resource Controllers laravel 4?

被刻印的时光 ゝ 提交于 2019-12-05 16:19:25

To use the PATH, PUT or DELETE HTML methods you need to add a hidden input with _method. Like the following...

<input type="hidden" name="_method" value="PUT" />

You can use the Form Builder. Example using blade:

{{ Form::open(array('method' => 'DELETE')) }}

That will automatically add this for you

<input name="_method" type="hidden" value="DELETE">

This works for me in Laravel 4:

{{ Form::open(array('url' => URL::to('customer/1'), 'method' => 'PUT')) }}

I am using Laravel resource controller. For update a page, I copied it from insert page after then

Just I added an extra field to update view like as

            {{ method_field('put') }}

Just use this as for update

 <form method="post" action="{{ URL::to('customer',$customer['id'])}}">
            {{ csrf_field() }}
            {{ method_field('put') }}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!