tahara
tahara

Reputation: 25

How to build a url with query string in a {{ Form }} in laravel 4.2?

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

Answers (2)

JofryHS
JofryHS

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

Oguzhan
Oguzhan

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

Related Questions