73874

Update route generates incorrect url

Question:

This is my html blade code

{{ Form::open(array('route' => 'restaurants.update', 'class' => 'mainInformationContrainer')) }} <ul> <li> <label>Website</label> <div class="oneInfo"> <input type="text" value="{{$restaurant->website}}" /> </div> </li> <li> <input type="submit" value="Save Changes"/> <input type="button" value="Cancle" class="cancelButton"/> </li> </ul> {{ Form::close() }}

But the url for the form is : public/restaurants/%7Brestaurants%7D

Thought I already have the route:

Route::resource('restaurants', 'RestaurantsController');

Answer1:

As @Mark Baker said %7B and %7D are { and } respectively , laravel expect you to pass the id of the resource you want to update.

If you see the <a href="http://laravel.com/docs/controllers#restful-controllers" rel="nofollow">board</a> with the action you will notice that you have to pass the resource id.

PUT/PATCH /resource/{resource} update resource.update

You can use the route helper function to fix it.

{{ Form::open(array('route' => route('restaurants.update', $restaurant->id), 'class' => 'mainInformationContrainer')) }}

Recommend

  • Load Same ACF Map Twice on Same Page
  • Function JavaScript : on Menu CSS HTML
  • Can't delete li from to-do list
  • WordPress > setting permalink option via script buggy?
  • Python PIL to extract number from image
  • Updating product post meta data in admin meta box field
  • sweetalert2 inputoptions from file in select example
  • Cut the background to expose the layer below
  • Cannot save model when using ember render helper
  • C#: Import/Export Settings into/from a File
  • Fail:(TESTMODE) Transactions of this market type cannot be processed on this system
  • nodemcu custom firmware build problems
  • xcode don't localize specific strings
  • Button click event not firing in jQuery
  • How can I set a binding to a Combox in a UserControl?
  • AJAX Html Editor Extender upload image appearing blank
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • Swift: Switch statement fallthrough behavior
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • JSON response opens as a file, but I can't access it with JavaScript
  • Typescript - Unable to get 'import' statement to function
  • FileReader+canvas image loading problem
  • Using jQuery closest() method with class selector
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Insert into database using onclick function
  • Is there any way to access browser form field suggestions from JavaScript?
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • Deselecting radio buttons while keeping the View Model in synch
  • req.body is undefined - nodejs
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • In LanguageTool, how do you create a dictionary and use it for spell checking?
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • what is the difference between the asp.net mvc application and asp.net web application
  • Jquery - Jquery Wysiwyg return html as a string
  • Matrix multiplication with MKL
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2