Hello, I'm creating a custom package that involves a CRUD resource. Because it involves extra steps, I DO NOT users to have to install the Form:: and Html:: facades and helpers.
So, I'm trying to create a standard form, but running into an error when I'm trying to do a "edit" form. For the opening form, I'm using this\
Normally, I would just use the Form Facade to bind the form. For example:
{{ Form::model($umduser, array('route' => array('umdusers.update', $umduser->id), 'method' => 'PUT')) }}
I've tried the following w/ variations, but no luck.
<form action="/umdusers/update" method="PUT">
Anyone know of the form action to use to edit/update a CRUD Resource?
Thanks! Troy
It needs an ID of the resource you're editing in the action param. I would recommend you doing a php artisan route:list it always helps me when I forget the syntax.
EDIT:
Relevant doc page: http://laravel.com/docs/5.1/controllers#restful-resource-controllers
@tepeters in HTML there's no actual method called PUT or PATCH - there's only GET and POST. So when you call Form::open with Laravel, it actually changes it to POST with hidden field. Something like this:
<form method="POST" action="xxxxxx/clients/20" accept-charset="UTF-8">
<input name="_method" type="hidden" value="PATCH">
I was able to find the solution using a named route as the action instead of an actual path. In addition, using the "POST" method similar to @PovilasKorop (thanks!)
Here's the solution for the opening tag:
<form action="{{ route('umdusers.update', $umduser->id) }}" method="POST">
<input type="hidden" name="_method" value="PUT">
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community