Question

I have made a form on home page in hello.blade.php file , with form value

{{ Form::open(array('route' => 'home/addguest', 
                        'class' => "form-horizontal")) }}

I have defined a method named addGuest() in HomeController which adds values in database and sends email.

I am getting error on home page as

ErrorException

Route [home/addguest] not defined. (View: /var/www/laravel/app/views/hello.blade.php)

Route.php has

Route::post('Home/addGuest', array('uses' => 'HomeController@addGuest'));

Route::get('/home', function()
{
    return View::make('home');
});

What value shall I define in form attribute to post this data and save that in the database?
Shall I change the form post target or shall I change the homecontroller method?

Was it helpful?

Solution

In route.php

Route::post('Home/addGuest', array('uses' => 'HomeController@addGuest'));

Should be

Route::post('Home/addGuest', array('as' => 'addguest', 'uses' => 'HomeController@addGuest'));

The "as" is the naming of the route, that you are refering to in the form. Be sure to update the Forms route to just "addguest" as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top