Reputation: 25
I have a url in address bar with some query string and I need a form in laravel blade generate a url to the same url in the address bar.
What I've done so far is:
{{ \Form::open(['url' => \URL::to('oauth/authorize') . '?' . http_build_query($_GET)]) }}
Is this the right way or is there any other way to generate it (a default laravel function maybe) ?
Upvotes: 1
Views: 1465
Reputation: 5874
I believe your way is fine, and there is no 'default' Laravel way of doing so.
But an alternative (slightly more Laravel-ish way), you can try
{{ \Form::open([
'url' => url('oauth/authorize') . '?' . http_build_query(\Request::query())
]) }}
You can check all the stuff you can get from current request from the API doc on Request
Upvotes: 1
Reputation: 734
Example
Route::get('car', function(){
echo Form::open(array('url' => 'car/search/', 'method' => 'get'));
echo Form::text('search');
echo Form::submit('Click Me!');
echo Form::close();
});
Route::get('car/search', function(){
return Input::get('search');
});
Upvotes: 0