JoeMaher's avatar

Submitting GET form doesn't trigger route

So i have a very strange problem occurring at the moment where i have a form that that submits as POST and triggers the route fine, whereas if the the form submits as GET it does not get triggered. It is just the strangest thing, in its simplified form the code looks like:

Works

route:

route::post('/contributions/finalise', [ 'as' => 'contributions.finalise', 'uses' => function() {
    dd('i get output');
}]);

form:

{!! Form::open(['route' => 'contributions.finalise', 'method' => 'POST']) !!}

    {!! Form::input('hidden','amount', null, ['id' => "contribute-amount"]) !!}

    <button type="submit">Submit</button>

{!! Form::close() !!}

Doesn't work

route:

route::get('/contributions/finalise', [ 'as' => 'contributions.finalise', 'uses' => function() {
    dd('i DONT get output, only a white screen is shown.');
}]);

form:

{!! Form::open(['route' => 'contributions.finalise', 'method' => 'GET']) !!}

    {!! Form::input('hidden','amount', null, ['id' => "contribute-amount"]) !!}

    <button type="submit">Submit</button>

{!! Form::close() !!}

As you can see they are very similar but the GET just doesn't work? Am i missing something really basic here?

Thanks for your help

0 likes
6 replies
bestmomo's avatar

Maybe there is a route that intercept this one.

1 like
bashy's avatar

You have two routes with the same name?

JoeMaher's avatar

I don't think there is, here is my routes

<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

//Route::get('/', 'WelcomeController@index');

/* Pages */

Route::get('/', 'PagesController@landing');
Route::get('/howItWorks', 'PagesController@howItWorks');

/* People */

Route::resource('users', 'UsersController');
Route::resource('celebrities', 'CelebritiesController');

/* Likes */

Route::resource('users.likes', 'Likes\UserLikesController');
Route::resource('celebrities.likes', 'Likes\CelebrityLikesController');

/* Contributions */

Route::resource('users.contributions', 'Contributions\UserContributionsController');
Route::resource('celebrities.contributions', 'Contributions\CelebrityContributionsController');
Route::resource('contributions', 'Contributions\ContributionsController');

Route::get('/users/{id}/contributions/finalise', [ 'as' => 'users.contributions.finalise', 'uses' => 'Contributions\UserContributionsController@finalise']);
Route::get('/celebrities/{id}/contributions/finalise', [ 'as' => 'celebrities.contributions.finalise', 'uses' => 'Contributions\CelebrityContributionsController@finalise']);


route::get('/contributions/finalise', [ 'as' => 'contributions.finalise', 'uses' => function() {
    dd('????');
}]);
/* Auth */

Route::controllers([
    'auth' => 'Auth\AuthController',
    'password' => 'Auth\PasswordController',
]);

Route::get('/confirm/verify/{confirmationCode}', 'UsersController@confirm');
Route::get('/confirm/not-confirmed', 'UsersController@notConfirmed');
Route::post('/confirm/resend-email', [ 'as' => 'confirm.resend', 'uses' => 'UsersController@resendEmail']);

route::get('/loginRedirect', function() {
    return Redirect::to('/users/' . Auth::id());
});

/* Leaderboard */

Route::get('/leaderboard/users', [ 'as' => 'leaderboard.uses', 'uses' => 'UsersController@leaderboard']);

/* Instagram */

Route::get('/feeds/instagram/{how_many}', 'InstagramFeedController@get');

/* Sharing/Nominating */

Route::get('/nomination/facebook', 'SharingNominatingController@showNomination');
Route::get('/nomination/twitter', 'SharingNominatingController@showTwitterNomination');
Route::post('/share/sendMail', [ 'as' => 'share.sendMail', 'uses' =>'SharingNominatingController@shareViaMail']);

/* Searching */

Route::get('/search', [ 'as' => 'search', 'uses' => 'SearchController@showSearch']);
Route::post('/search/perform', [ 'as' => 'search.perform', 'uses' => 'SearchController@performSearch']);

Even without the form, just navigation http://localhost:8888/contributions/finalise displays a plain white screen no errors no output

bestmomo's avatar
Level 52

Maybe this one :

Route::resource('contributions', 'Contributions\ContributionsController');
2 likes
bashy's avatar

Yeah it's that resource one. You should also turn on debug/errors, you'd see the error displayed as something.

1 like
JoeMaher's avatar

Omg i can't believe that, It was interpreting the 'finalise' of the url as a Contribution and triggering the 'show' method of the contribution resource, how simple XD.

Thank you both :)

Please or to participate in this conversation.