I have a form with 2 submit buttons;
<form class="form-horizontal" role="form" method="GET" action="{{ URL::to('split_form') }}">
{!! Form::hidden('postcode_id', $postcode_lookup['id']) !!}
<input class="btn btn-warning" type="submit" name="action" value="CSV" />
<input class="btn btn-info" type="submit" name="action" value="Map" />
</form>
Here is my routes.php;
Route::get('split_form', array(
'before' => 'form_splitter',
function()
{
print "three";
Route::get('/export/csv', 'ExcelController@index');
Route::get('/map/all', 'MapController@index');
}
));
Here is my app/filters.php file;
<?php
Route::filter('form_splitter', function()
{
if ( Input::get('action') === 'CSV' )
{
Redirect::to('/export/csv');
print "one";
}
elseif ( Input::get('action') === 'Map' )
{
Redirect::to('/map/all');
print "two";
}
});
I'm doing just a couple of "hello worlds" on the two controllers at the moment but all I get back from the browser is "three". Do I have to register filters.php somewhere?
its either on your composer.json
"files": ["app/filters.php"]
Or you can create a service provider and load(include) it from there.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community