1

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) ?

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for pointing me at the Request, forgot about that... :)
0

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');
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.