Laravel 4 - How do I submit a form to add comments to a page with a URL variable?

Ian Woodfill

I have a system where you go to http://example.com/restaurant/restaurant-key-example and you can view a given restaurant. I have a form at the bottom with reviews that can be added to the restaurant.

//Restaurant info page(GET)
Route::get('/restaurant/{key}', array(
    'as' => 'restaurant-show',
    'uses' => 'RestaurantController@getRestaurant'
));

//Restaurant review submit(POST)
Route::get('/restaurant/review/{key}', array(
    'as' => 'restaurant-review-post',
    'uses' => 'RestaurantController@postAddReview'
))->before('csrf');

{{ Form::open(['route' => 'RestaurantController@postAddReview']) }} and when I submit it, it goes to http://example.com/restaurant/key?restaurant-key-example. Is their any good way I can do this? What am I doing wrong? Any and all help is appreciated!

Cowwando

First should never post any forms and data with GET, but POST. This means you have to rework your route to Route::post('....');

After that you dont need that parameter in there! In your method in that controller you need to check for all the inputs by this:

$inputs = Input::except('_token');

and var_dump it if you want to check what you have posted!

Regards and tell me if you need any further help!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I add a variable id belonging to each form post to localStorage everytime I submit a form?

How do I add a submit button, and specify that the form should go to "/action_page.php"?

How do I submit a PUT method form in Laravel without reloading the page?

How do I redirect to another page on form submit?

How do I submit the first form on a page with JavaScript?

React.js - How do I submit a form on page load?

How do I handle multiple submit buttons in a single form with Laravel?

How to do a page slide transition on form submit?

NSwag - how do I add comments?

How do I change form data on submit?

How can i submit form keeping existing query string intact in url in laravel

How do I clear Bootstrap 4 errors after I submit my React form?

How do I submit a form's data to another function without refreshing the page?

In Rails 4 how do I add fields to a form in a DRY manner?

How do I add my objects to an array on form submit using JSON and PHP?

How Do I Add Google Analytics OnClick To Wordpress Contact Form 7 Submit Button

How to add a AJAX submit form inside a notification without reloading the page?

How do I form submit input data to display in another view in Laravel 6

How to fixed page reload same on form submit with laravel

how to return to a specific page after form submit based on value laravel

How do I make a form with only hidden inputs inside a Bootstrap (4) modal submit on enter?

Angular4: How do I build a dynamic list of checkboxes to submit in a form?

How to add values/names of checkbox to a variable on form submit?

How do I open a file from a URL in Laravel 4

Submit a form in vue. How do I reference the form element?

How to add additional input with value in modal before form submit in laravel

How to do a form submit in moodle from some other page?

How can I add HTML comments with an URL to an XML file?

How to add $_POST['variable'] to URL of next page?